ybkuroki / rails-webapp-sample

Ruby on Rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rails-webapp-sample

Preface

This sample project uses Ruby on Rails. It provides only Web API. So, I recommend using a vuejs-webapp-sample project as Web UI.

Install

Perform the following steps:

  1. Download and install Ruby.
  2. Download and install Rails.
    gem install rails
    gem install bundler
  3. Download and install Visual Studio Code(VS Code).
  4. Clone this repository.
  5. Download and install dependencies.(Only development environment)
    bundle install --without=production
    If install dependencies in the production server:
    bundle install

Starting Server

Perform the following steps:

  1. Start the development server.
    rails s -p 8080
  2. When startup is complete, the console shows the following message:
    => Booting Puma
    => Rails 5.2.0 application starting in development 
    => Run `rails server -h` for more startup options
    Puma starting in single mode...
    * Version 3.11.4 (ruby 2.5.1-p57), codename: Love Song
    * Min threads: 5, max threads: 5
    * Environment: development
    * Listening on tcp://localhost:8080
    Use Ctrl-C to stop
    
  3. Log in with the following username and password.
    • username : test
    • password : password

Project Map

The follwing figure is the map of this sample project.

- rails-webapp-sample
  - app
    + controllers           … Define controllers.
    + models                … Define models.
    + services              … Define services.
  + config                  … Define configurations such as database connections, dependency libraries, and routings.
  + db                      … Define SQL files to migrate models to the database.
  - Gemfile                 … Define Rails Libraries.

Services

This sample provides 3 services: book management, account management, and master management.

Book Management

There are the following services in the book management.

Service Name HTTP Method URL Parameter Summary
List Service GET /api/book/list Page Get a list of books.
Regist Service POST /api/book/new Book Regist a book data.
Edit Service POST /api/book/edit Book Edit a book data.
Delete Service POST /api/book/delete Book Delete a book data.
Search Title Service GET /api/book/search Keyword, Page Search a title with the specified keyword.
Report Service(No implementation) GET /api/book/allListPdfReport Nothing Output a list of books to the PDF file.

Account Management

There are the following services in the Account management.

Service Name HTTP Method URL Parameter Summary
Login Service POST /api/account/login Session ID, User Name, Password Session authentication with username and password.
Logout Service POST /api/account/logout Session ID Logout a user.
Login Status Check Service GET /api/account/loginStatus Session ID Check if the user is logged in.
Login Username Service GET /api/account/loginAccount Session ID Get the login user's username.

Master Management

There are the following services in the Master management.

Service Name HTTP Method URL Parameter Summary
Category List Service GET /api/master/category Nothing Get a list of categories.
Format List Service GET /api/master/format Nothing Get a list of formats.

Libraries

This sample uses the following libraries.

Library Name Version Summary
rails 6.0.0 Rails
sqlite3 1.4.1 Provides the database connection service.
kaminari 1.1.1 Provides the concept of pagination.
rack-cors 1.0.2 Library handling for CROS.

License

The License of this sample is MIT License.

About

Ruby on Rails

License:MIT License


Languages

Language:Ruby 99.5%Language:HTML 0.5%