59

I have a simple model that mounts a Carrierwave uploader. Everything works fine in development, but I get an undefined method "image_will_change!" error on heroku.

class Receipt < ActiveRecord::Base
  mount_uploader :image, ImageUploader
end

class ImageUploader < CarrierWave::Uploader::Base
  storage :fog
  def store_dir
    "receipts/saved"
  end
end

I have the cache_dir set appropriately as well according to the Carrierwave Wiki.

receipt.image = File.open "public/images/test.jpg" #works fine in development, fails in heroku
Sean Coleman
  • 1,287
  • 2
  • 10
  • 10
  • I ran into the same error message, and even though I did rake db:migrate, the error still didn't go away. So I ended up upgrading to the new Cedar stack, and it worked. I suspect though if I dropped the database, and redo the entire migration, it would have worked as well. – sivabudh Aug 21 '11 at 04:25

3 Answers3

145

It's likely that your db on heroku doesn't have the image column in the receipts table.

Jack Dempsey
  • 2,024
  • 1
  • 16
  • 6
19

Even after running the migration on heroku, the error persisted.

I found that a heroku restart command was required to vanquish the error forever.

heroku restart
philip_kobernik
  • 426
  • 5
  • 7
  • 1
    Just wanted to let you know that you saved my life. I was *this* close to leaping from my office window in frustration before I found this. – vlasits Jun 10 '13 at 18:09
  • Wow! Found this after 30 mins of searching ! Worked for me! – newbie Nov 20 '14 at 01:09
7

It's probably because you forgot to run:

rake db:migrate
Eduardo Santana
  • 5,780
  • 3
  • 19
  • 21