has_attached_file error in rails migration

138 views
Skip to first unread message

Karthik

unread,
Jan 13, 2012, 4:55:25 AM1/13/12
to Paperclip Plugin
Hello people,

I installed paperclip gem with these following lines in gem file

gem 'rmagick'
gem "paperclip", "~> 2.0"
gem 'aws-s3'

I am using amazon S3.

the problem came when I ran the migration which had the following
migration code

class AddImageColumnsToPicture < ActiveRecord::Migration
def self.up
change_table :pictures do |t|
t.has_attached_file :image
end
end

def self.down
drop_attached_file :pictures, :image
end
end

It gave the following error:

An error has occurred, this and all later migrations canceled:

undefined method `has_attached_file' for
#<ActiveRecord::ConnectionAdapters::Table:0xb414d98>

Any one knows how to fix it?

Shailesh Kalamkar

unread,
Apr 18, 2012, 7:50:50 AM4/18/12
to papercli...@googlegroups.com
Try to include paperclip in the model as

  include Paperclip
Reply all
Reply to author
Forward
0 new messages