I am trying to add two different attachment fields. The migration is failing wether i run it using bundler or without. (bundle exec rake db:migrate or just rake db:migrate).
== AddDiagramToQuestion: migrating ===========================================
-- change_table(:questions)
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `has_attached_file' for #<ActiveRecord::ConnectionAdapters::Table:0x0000012b003b20>
/Users/kboon/Documents/workspace/quiztaker/db/migrate/20111213182927_add_diagram_to_question.rb:6:in `block in up'
/Users/kboon/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/schema_statements.rb:244:in `change_table'
The migration looks like this:
class AddDiagramToAnswer < ActiveRecord::Migration
def self.up
change_table :answers do |t|
t.has_attached_file :diagram
end
end
def self.down
drop_attached_file :answers, :diagram
end
end
The model also references methods added by paperclip and the app runs fine so its not that paperclip isn't installed at all. I've even tried added require 'paperclip' to the migration but that didn't help at all.
Gemfile
? – Transcendentalistic20111213182927_add_diagram_to_question.rb:6
but your posted migration is foranswers
rather thanquestions
. Have you posted the correct migration file here? – Dagenhamrails g paperclip question diagram
. – Storerrequire "paperclip"
in your migration file? – Lid