undefined method `attachment_will_change!'

carrierwave, ruby-on-rails

Solution

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

Problem

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 ```

Original source

Related problems