Rails Railscasts 视频中 #009 File uploading by Carrierwave

menghuanwd · November 17, 2012 · Last by menghuanwd replied at November 18, 2012 · 2683 hits

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

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

You need to Sign in before reply, if you don't have an account, please Sign up first.