use*_*901 0 ruby ruby-on-rails ruby-on-rails-4
ActiveModel :: ForbiddenAttributesError提取的源(第3行):
Rails.root:C:/ Users/ManU/Desktop/quick_blog应用程序跟踪| 框架跟踪| 完整追踪
app/controllers/comments_controller.rb:4:在'create'中
我应该怎么做来处理这个错误.....请给我解决路径以及...我没有事先知道这个.....
您似乎正在使用rails 4跟踪pre rails 4.0教程.您现在需要使用强params.
http://guides.rubyonrails.org/action_controller_overview.html#strong-parameters
还有一个应该有帮助的railscast.
@comment = @post.comments.create!(params.require(:comment).permit!)
@comment = @post.comments.create!(params.require(:comment).permit(:comment_text,:link))
Run Code Online (Sandbox Code Playgroud)
第一个允许允许所有参数,后者只允许comment_text并被link接受.
| 归档时间: |
|
| 查看次数: |
2675 次 |
| 最近记录: |