前几天我创建了用于添加Paperclip头像的轨道迁移,但最终走向了一个不同的方向。作为Rails的新手,我不知道如何像我一样删除迁移文件。已删除的迁移和Heroku
我的应用程序工作正常本地,但运行时heroku run rake db:migrate
我得到这个:
undefined method `attachment' for #<ActiveRecord::ConnectionAdapters::Table:0x000000046092e0>
这是因为它试图运行迁移称为AddAttachmentAvatarToVenues
,这是迁移我愣神删除。
它也为删除迁移中指定的化身添加了列到schema.rb
,但我创建了一个新的迁移来摆脱这些。新迁移摆脱了他们,但没有改变heroku迁移错误。
任何想法如何解决这个问题?我做了大量的搜索和环顾,所以有很多人有类似的错误,他们大多是他们使用的命令的问题。
以下是在我的heroku迁移中尝试删除的迁移后的输出。
== AddAttachmentAvatarToVenues: migrating ====================================
-- change_table(:venues)
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `attachment' for #<ActiveRecord::ConnectionAdapters::Table:0x00000003bdb7c8>
/app/db/migrate/20130206222434_add_attachment_avatar_to_venues.rb:4:in `block in up'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/schema_statements.rb:243:in `change_table'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:466:in `block in method_missing'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:438:in `block in say_with_time'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:438:in `say_with_time'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:458:in `method_missing'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:334:in `method_missing'
/app/db/migrate/20130206222434_add_attachment_avatar_to_venues.rb:3:in `up'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:370:in `up'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:410:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:410:in `block in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:389:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:528:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `block in ddl_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/transactions.rb:208:in `transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:775:in `ddl_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:719:in `block in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:700:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:570:in `up'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/migration.rb:551:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:179:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
我确实看到输出有什么问题,我只是不确定如何解决它而不会搞乱它。
编辑:这里的文件结构的一些截图:
(两个类似的命名者是因为有一个专栏中,我忘了删除,但是这是我在这个问题后没“T影响它无论哪种方式)
EDIT2:
这是从我的git历史中删除的迁移。在此之后,我添加了更多频道。他们只是几个字符串,但如果这可能会有所作为,我会找到一个更新的版本。
class AddAttachmentAvatarToVenues < ActiveRecord::Migration
def self.up
change_table :venues do |t|
t.attachment :avatar
end
end
def self.down
drop_attached_file :venues, :avatar
end
end
在此先感谢!
您能否显示迁移? – 2013-02-11 18:31:37
这就是问题所在,我从我的migrations文件夹中删除了它,我不确定它会从哪里来。 – Jason 2013-02-11 18:39:26
它不在吗? /app/db/migrate/20130206222434_add_attachment_avatar_to_venues.rb – 2013-02-11 18:40:18