パンくずリスト
書籍 RailsによるアジャイルWebアプリケーション開発
scaffoldの生成
概要
scaffoldの生成
詳細
以下のコマンドでテーブルの作成、モデル・ビュー・コントローラー・マイグレーションを作成できます。
例は商品テーブル及び関連処理を作成する
rails generate scaffold Product title:string description:text image_url:string price:decimal
実行時コンソール出力内容
invoke active_record create db/migrate/20130101130055_create_products.rb create app/models/product.rb invoke test_unit create test/unit/product_test.rb create test/fixtures/products.yml route resources :products invoke scaffold_controller create app/controllers/products_controller.rb invoke erb create app/views/products create app/views/products/index.html.erb create app/views/products/edit.html.erb create app/views/products/show.html.erb create app/views/products/new.html.erb create app/views/products/_form.html.erb invoke test_unit create test/functional/products_controller_test.rb invoke helper create app/helpers/products_helper.rb invoke test_unit create test/unit/helpers/products_helper_test.rb invoke assets invoke coffee create app/assets/javascripts/products.js.coffee invoke scss create app/assets/stylesheets/products.css.scss invoke scss create app/assets/stylesheets/scaffolds.css.scss