【发布时间】:2011-05-11 18:34:05
【问题描述】:
我有一个种子.rb 文件:
activity1 = Activity.create! :name => 'Football', :icon => File.read("#{Rails.root}/public/images/activity_icons/football.png")
但是当我运行 rake db:seed 时,进程失败并且我收到一条错误消息:
You tried to assign a String or a Pathname to an uploader, for security reasons, this is not allowed.
If this is a file upload, please check that your upload form is multipart encoded.
好吧,手动图标上传确实有效,因为我的表单是多部分编码的,所以我猜 rake 正在使用它自己的表单运行seeds.rb。
我必须做些什么才能完成这项工作?除了每次我重新创建我的数据库时手动添加图标
【问题讨论】:
-
您的文件附件使用什么插件/gem?回形针/attachment_fu?
-
我正在使用 CarrierWave(来自 github 的主分支)和 Fog
标签: ruby-on-rails ruby-on-rails-3 rake