我先执行了rails new myapp
rails generate scafflod ticket name:string
rake db:migrate
这是执行rails server
可以正常访问并创建对象。
现在我想增加 ticket 的项目,执行rails generate migration AddEmailToTickets email:string
rake db:migrate
修改 view 目录下的访问文件,在访问时,却出现了一下的错误:
ActiveModel::MassAssignmentSecurity::Error in TicketsController#create
Can't mass-assign protected attributes: email Rails.root: /home/lo/try/rails/ff
Application Trace | Framework Trace | Full Trace app/controllers/tickets_controller.rb:43:in `new' app/controllers/tickets_controller.rb:43:in `create' Request
Parameters:
{"utf8"=>"✓", "authenticity_token"=>"xFsJUy4zWJbLU3jxOaimoJHc8D0e8pR2N88RS5DEo1E=", "ticket"=>{"name"=>"asf", "address"=>"af", "price"=>"2323", "email"=>"wqer"}, "commit"=>"Create Ticket"} Show session dump
Show env dump
Response
Headers:
总是无法访问,不知是不是数据迁移没有成功还是怎么的,求解?