CarrierWave文件上传无法在rails中运行

我需要将图像上传到我的电影collections应用程序我使用carrierwave来执行此操作( 按照railscasts步骤 )

步骤1我将gem’carrierwave’,’〜> 0.9’添加到我的Gemfile然后运行bundle步骤2 rails g uploader image然后rails g scaffold filmes name moviestype rake db step 3 rails g migration add_image_to_filmes image:string然后rake db

其他步骤与railscasts相同

在我的电影模型中

attr_accessible :name, :moviestype, :image mount_uploader :image, ImageUploader 

在我的_form.html.erb中

  {:multipart => true} do |f| %>  

prohibited this filme from being saved:




在show.html.erb中

 

Name:

Moviestype:

|

问题是它没有上传任何图像,但电影名称和其他字段正在插入db.how我能解决这个问题吗?需要快速帮助。

根据错误日志,您不允许将image保存在数据库中。 在FilmesController ,您需要允许:image as

 def filme_params params.require(:filme).permit(:name, :moviestype, :image) ## Add :image attribute end