I’m using CarrierWave to attach icons to my activities model. I have a
bunch of seed data that I want to create every time I recreate my
database.
The following line from my seeds.rb file causes rake to throw and
error:
activity = Activity.create! :name => ‘Football’, :icon =>
File.read("#{Rails.root}/public/images/activity_icons/football.png")
As you can see, I’m trying to upload a file from my public directory
when I run rake db:seed.
But when I do this, I get a complaint about my form not being
multipart encoded. I know that my form IS multipart encoded because
manual uploads work fine and I’ve added the necessary code i.e. (:html
=> {:multipart => true}) to my form
I’m guessing that this is not a CarrierWave issue since it would
almost certainly happen if I was using paperclip or attachment_fu but
perhaps some of you have dealt with this issue before?
It seems to me that rake is not using the same form that is used for
manual uploads (makes sense really) so is there a way to tell rake
that this seed data should be considered multipart encoded?