title: How can I access files from a rake task on heroku?
body: <p>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! </p>
  
  <p><a href="https://stackoverflow.com/a/64822/1449799">rake task + yml files for seeding</a></p>
  
  <p><a href="https://stackoverflow.com/a/3913323/1449799">seeding carrierwave</a></p>
  
  <p>I have the following:</p>
  
  <pre><code>namespace :db do
    desc "This loads the development data."
    task :seed =&gt; :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 =&gt; [:environment, 'db:reset', 'db:seed']
  end
  </code></pre>
  
  <p>However on heroku, I keep getting errors about the path such as </p>
  
  <pre><code>rake aborted!
  No such file or directory - app/assets/images/objects/house.svg
  </code></pre>
  
  <p>I have tried several versions of the line: </p>
  
  <pre><code>item.filename.store!(File.open(File.join(Rails.root, "app/assets/images/objects/" + item.name.gsub(/ /,'').downcase + ".svg")))
  </code></pre>
  
  <p>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.</p>