我正在使用 Paperclip 创建 Pinterest 克隆,并且我正在尝试扫描我的迁移文件,但出现错误:
我能够运行生成 cmd:
pinterested-app git:(master) ✗ rails generate paperclip user image
Running via Spring preloader in process 88926
create db/migrate/20170511010912_add_attachment_image_to_users.rb
但是当我跑试图耙数据库时,我得到了以下信息:
➜ pinterested-app git:(master) ✗ rake db:migrate
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
class AddAttachmentImageToUsers < ActiveRecord::Migration[4.2]
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:525:in `inherited'
/Users/rthomas/Dropbox/rails-dev/pinterested-app/db/migrate/20170511010912_add_attachment_image_to_users.rb:1:in `<top (required)>'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `block in require'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activesupport-5.1.0/lib/active_support/dependencies.rb:292:in `require'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:962:in `load_migration'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:958:in `migration'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:953:in `disable_ddl_transaction'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:1305:in `use_transaction?'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:1297:in `ddl_transaction'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:1229:in `execute_migration_in_transaction'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:1201:in `block in migrate_without_lock'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:1200:in `each'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:1200:in `migrate_without_lock'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:1150:in `migrate'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:1007:in `up'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/migration.rb:985:in `migrate'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/Users/rthomas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.0/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/Users/rthomas/.rvm/gems/ruby-2.4.0@global/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
由于 Rails 要求指定 Rails 版本并且您使用的是 Rails 5.1,请尝试在迁移文件的 ActiveRecord::Migration 末尾添加 [5.1]:
class AddAttachmentImageToUsers < ActiveRecord::Migration[5.1]
然后再次尝试运行。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句