1

I have never seen this error before, undefined method 'attachment_will_change!' for #<Movie:0x00000106b16000>

Possibly something to do with carrierwave.

Params in movie model.

def movie_params
   params.require(:movie).permit(:title, :rating, :total_gross, :attachment)
end

carrierwave.rb in initializers.

CarrierWave.configure do |config|

  config.fog_credentials = {

    :provider               => 'abc',        # required
    :aws_access_key_id      => 'abcabc',     # required
    :aws_secret_access_key  => 'abcabcabc',  # required

  }

  config.fog_directory  = 'abcabc'  # required
  config.fog_public     = false     # optional, defaults to true
  config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}

end

imageuploader

   include CarrierWave::MiniMagick

storage :fog

    def store_dir
        "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
      end

     version :thumb do
        process :resize_to_fit => [50, 50]
      end

     def extension_white_list
        %w(jpg jpeg gif png)
      end

    end
Pavan
  • 33,316
  • 7
  • 50
  • 76
Spencer Hire
  • 735
  • 3
  • 14
  • 32
  • 1
    Some related links http://stackoverflow.com/questions/5481331/undefined-method-image-will-change-for-carrierwave-on-heroku http://stackoverflow.com/questions/7491595/carrierwave-rails-3-1-undefined-method-image-will-change might be useful. – Pavan Jul 10 '14 at 06:18
  • According to the related links,you should be having `attachment` attribute in your `movies` table.Do you have it? – Pavan Jul 10 '14 at 06:20
  • That second question answered that for me, do you want to create answer then i can accept. – Spencer Hire Jul 10 '14 at 06:32
  • Yup, missing column in table. – Spencer Hire Jul 10 '14 at 06:32
  • Well,then i will post my answer :) – Pavan Jul 10 '14 at 06:33

1 Answers1

5

As i said,you are missing attachment attribute in your movies table.You have to add attachment column in order to fix that error.

undefined method 'attachment_will_change!'

Generate a migration file by the following command

rails g migration AddAttachementToMovies attachement:string

It will generate a migration file something like this

class AddAttachmentToMovies < ActiveRecord::Migration
  def change
    add_column :movies, :attachment, :string
  end
end

And then do rake db:migrate

Source

Community
  • 1
  • 1
Pavan
  • 33,316
  • 7
  • 50
  • 76