Rails Railscasts 视频中 #009 File uploading by Carrierwave

menghuanwd · 2012年11月17日 · 最后由 menghuanwd 回复于 2012年11月18日 · 2684 次阅读

我按照视频教程上照做的 在保存的时候出现这个错误:

ActiveModel::MassAssignmentSecurity::Error in PostsController#create

Can't mass-assign protected attributes: attachmentable Rails.root: /home/user/upload

Application Trace | Framework Trace | Full Trace app/controllers/posts_controller.rb:48:in block in create' app/controllers/posts_controller.rb:45:increate' Request

Parameters:

{"utf8"=>"✓", "authenticity_token"=>"n7Si25bOgGofURmyxghGYYJrHdyj4IYEljLkFUfIZpg=", "post"=>{"title"=>"w", "content"=>"w"}, "attachment"=>"03.jpg", "commit"=>"Create Post"} Show session dump

求高手解答下:

你的 model 添加 attr_accessible :attachmentable

需要 登录 后方可回复, 如果你还没有账号请 注册新账号