新規アプリを作る
$ rails new sample -d mysql
$ cd sample
(bundleをスキップする場合)
$ rails new sample -d mysql --skip-bundle
コントローラーを作る
cd /root/sample/app/controllers
rails generate controller test
コントローラーtest
class TestController < ApplicationController
def hello
render:text=>'hello'
end
def bye
render:text=>'bye'
end
end
//config/database.ymlの内容でデータベースを作る
$ rake db:create
ルーティングを作成
$ vim config/routes.rb
-------------
Rails.application.routes.draw do
match ':controller(/:action(/:id))', via: [ :get, :post, :patch ]
end
-------------
ルーティングをcheck
$ rake routes
サーバー起動
$ rails s --port=80