概要
Controllerの生成
サンプル
自動生成実行
※RSpec、Haml環境です。デフォルト構成ならTest,ERBが生成されます
$ rails g controller sample index
create app/controllers/sample_controller.rb
route get "sample/index"
invoke haml
create app/views/sample
create app/views/sample/index.html.haml
invoke rspec
create spec/controllers/sample_controller_spec.rb
create spec/views/sample
create spec/views/sample/index.html.haml_spec.rb
invoke helper
create app/helpers/sample_helper.rb
invoke rspec
create spec/helpers/sample_helper_spec.rb
invoke assets
invoke coffee
create app/assets/javascripts/sample.js.coffee
invoke scss
create app/assets/stylesheets/sample.css.scss
生成内容
sample_controller.rb
class SampleController < ApplicationController def index end end
app/views/sample/index.html.haml
%h1 Sample#index %p Find me in app/views/sample/index.html.haml