I am trying to seed data in a Rails app, particularly one using carrierwave. I am using a combination of 2 nice solutions found here on stackoverflow!
rake task + yml files for seeding
I have the following:
namespace :db do
  desc "This loads the development data."
  task :seed => :environment do
    require 'active_record/fixtures'
    Dir.glob(RAILS_ROOT + '/db/fixtures/*.yml').each do |file|
      base_name = File.basename(file, '.*')
      puts "Loading #{base_name}..."
      ActiveRecord::Fixtures.create_fixtures('db/fixtures', base_name)
    end
    #add in the image file for the default data
    for item in Item.find(:all)
      item.filename.store!(File.open(File.join(Rails.root, "app/assets/images/objects/" + item.name.gsub(/ /,'').downcase + ".svg")))
      item.save!
    end
  end
  desc "This drops the db, builds the db, and seeds the data."
  task :reseed => [:environment, 'db:reset', 'db:seed']
end
However on heroku, I keep getting errors about the path such as
rake aborted!
No such file or directory - app/assets/images/objects/house.svg
I have tried several versions of the line:
item.filename.store!(File.open(File.join(Rails.root, "app/assets/images/objects/" + item.name.gsub(/ /,'').downcase + ".svg")))
where I basically changed out using File.join and just concatenation and also trying to use the RAILS_ROOT which seemed to work ok above, but I always seem to get this error.
 
     
     
    