Undefined method `image_will_change!' for CarrierWave on Heroku

Ruby on-Rails-3HerokuCarrierwave

Ruby on-Rails-3 Problem Overview


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

Ruby on-Rails-3 Solutions


Solution 1 - Ruby on-Rails-3

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

Solution 2 - Ruby on-Rails-3

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

Solution 3 - Ruby on-Rails-3

It's probably because you forgot to run:

rake db:migrate

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSean ColemanView Question on Stackoverflow
Solution 1 - Ruby on-Rails-3Jack DempseyView Answer on Stackoverflow
Solution 2 - Ruby on-Rails-3philip_kobernikView Answer on Stackoverflow
Solution 3 - Ruby on-Rails-3Eduardo SantanaView Answer on Stackoverflow