ログ出力
var = "World"
logger.debug "Hello #{var}"
bundleは
bundle installと同じ意味である
rails dbconsoleでmysqlにログインすればuse developmentされた状態になる
routes確認
rake routes
newアクション 新規登録画面を表示する(APIの場合は不要)
createアクション 新規登録処理
Active Recordにscopeメソッドがある。
class Book < ActiveRecord::Base scope :comic, where(:category => 'Comic') end
validatesは以下のメソッドを呼び出したタイミングで実行される。
create
create!
save
save!
update
update_attributes
update_attributes!
rake db:migrate:reset
これは以下のコマンドと同じ
rake db:drop
rake db:create
rake db:migrate
Shopテーブルの前レコードを削除したい場合のコマンド
rails console
irb(main):001:0> Shop.delete_all