In a rake task for production to migrate some assets I want to require a model that uses Paperclip. But I get the error
NoMethodError: undefined method `has_attached_file' for #<Class:0x00000006c12680>
~/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-3.2.18/lib/active_recor/dynamic_matchers.rb:55:in `method_missing'
/app/models/user.rb:74:in `<class:User>'
Line 74 declares the attachment:
has_attached_file :photo, styles: { original: '1024x1024>', s64: ["64x64#", "jpg"] },
:convert_options => { original: "-quality 85 -strip", s64: "-quality 85 -strip" },
processors: [:trimmer, :cropper], url: '/system/product/:attachment/:id/:style/:filename',
path: ':rails_root/public/system/product/:attachment/:id/:style/:filename'
from the Rakefile: lib/task/asset.rake
task :preload => :environment do
require 'user'
end
I tried to require 'paperclip'
before 'user', but it didn't help.