2017-07-20 3 views
0

こんにちは、私はpaperclip gem(5.1)をインストールした後に、iアプリをビルドする必要があります。私がタイトルでrake db:migrate does not workと言いました。私は、いくつかのソリューションで提案されているように、レールサーバとノートパソコンを再起動しようとしましたが、[5.1]をActiveRecord :: Migrationの隣に追加してみました。rake db:paperclip gemがインストールされた後にマイグレーションが行われない

class CreatePics < ActiveRecord::Migration[5.1] 

一部のバージョンを変更してもまだ動作しません。 その有用コードプロジェクトは、ここでhttps://github.com/leobouts/Instagramm

をある場合、私は取得エラーが

rake db:migrate --trace 
** Invoke db:migrate (first_time) 
** Invoke environment (first_time) 
** Execute environment 
** Invoke db:load_config (first_time) 
** Execute db:load_config 
** Execute 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 AddAttachmentImageToPics < ActiveRecord::Migration[4.2] 
/Users/leonidas/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.2/lib/active_record/migration.rb:525:in `inherited' 
/Users/leonidas/Desktop/Instagramm/db/migrate/20170719181859_add_attachment_image_to_pics.rb:1:in `<top (required)>' 
/Users/leonidas/.rvm/gems/ruby-2.4.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `require' 

であり、あなたがRailsの3を使用するなど、この

+0

あなたは私はあなたがRailsの3を使用しているとマイグレーションクラスのバージョン番号だけレール5で追加され、バージョン番号なしでクラス名を持っている必要がありますね、ここ –

+0

をAddAttachmentImageToPicsの移行を含める必要があります。 'class CreatePics Pavan

+0

あなたのデータベースをリセットすることをお勧めします:rake db:reset – Snake

答えて

0

のように延々と続く、マイグレーションクラス必要がありますversion numberではありません。 AFAIK、マイグレーションクラスのversion numberは、Rails 5.xバージョンでのみ追加されています。クラスを変更すると、エラーが修正されます。

class CreatePics < ActiveRecord::Migration 

class AddAttachmentImageToPics < ActiveRecord::Migration 
関連する問題