Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Directly inheriting from ActiveRecord::Migration is not supported #2465

Closed
acandael opened this issue Jul 9, 2017 · 1 comment
Closed

Directly inheriting from ActiveRecord::Migration is not supported #2465

acandael opened this issue Jul 9, 2017 · 1 comment

Comments

@acandael
Copy link

acandael commented Jul 9, 2017

this error is given when trying to run a migration generated with the paperclip generator:

rails g paperclip absence document

the error is:

Directly inheriting from ActiveRecord::Migration is not supported. Please specify
 the Rails release the migration was written for:

the Rails version I use is 5.1.2

I fixed the issue by putting
[5.1]
at the end of ActiveRecord::Migration:

class AddAttachmentDocumentToAbsences < ActiveRecord::Migration[5.1]
@jackellenberger
Copy link
Contributor

jackellenberger commented Jul 18, 2017

Same issue, same solution.

diff --git a/db/migrate/20170718022803_add_attachment_image_to_posts.rb b/db/migrate/20170718022803_add_attachment_image_to_posts.rb
index accf44e..93f1785 100644
--- a/db/migrate/20170718022803_add_attachment_image_to_posts.rb
+++ b/db/migrate/20170718022803_add_attachment_image_to_posts.rb
@@ -1,4 +1,4 @@
-class AddAttachmentImageToPosts < ActiveRecord::Migration
+class AddAttachmentImageToPosts < ActiveRecord::Migration[5.1]
   def self.up
     change_table :posts do |t|
       t.attachment :image

Steps to reproduce:

  • create new rails project
  • rails g model Post title cost:decimal body:text
  • rails g paperclip post image
  • rake db:migrate

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants