You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
Paperclip is currently undergoing deprecation in favor of ActiveStorage. Maintainers of this repository will no longer be tending to new issues. We're leaving the issues page open so Paperclip users can still see & search through old issues, and continue existing discussions if they wish.
I know this is deprecated, but I am doing a course where I have to use this gem instead of ActiveStorage or Carrierwave.
The problem is, in Rails 6.0, whenever I run rails db:{drop,create,migrate} I get:
Dropped database 'db/development.sqlite3'
Dropped database 'db/test.sqlite3'
Created database 'db/development.sqlite3'
Created database 'db/test.sqlite3'
== 20200914221802 CreatePictures: migrating ===================================
-- create_table(:pictures)
-> 0.0048s
== 20200914221802 CreatePictures: migrated (0.0050s) ==========================
== 20200916062631 DeviseCreateUsers: migrating ================================
-- create_table(:users)
-> 0.0053s
-- add_index(:users, :email, {:unique=>true})
-> 0.0019s
-- add_index(:users, :reset_password_token, {:unique=>true})
-> 0.0040s
== 20200916062631 DeviseCreateUsers: migrated (0.0150s) =======================
== 20200916063812 AddUserIdToPics: migrating ==================================
-- add_column(:pictures, :user_id, :integer)
-> 0.0048s
== 20200916063812 AddUserIdToPics: migrated (0.0049s) =========================
== 20200916064238 AddUsernameToUsers: migrating ===============================
-- add_column(:users, :username, :string)
-> 0.0060s
== 20200916064238 AddUsernameToUsers: migrated (0.0062s) ======================
rails 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]
/home/sourav/railsProjects/InstagramApp/db/migrate/20200919075557_add_attachment_image_to_pics.rb:1:in `<main>'
/home/sourav/railsProjects/InstagramApp/bin/rails:9:in `<top (required)>'
/home/sourav/railsProjects/InstagramApp/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Caused by:
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
class AddAttachmentImageToPics < ActiveRecord::Migration[4.2]
/home/sourav/railsProjects/InstagramApp/db/migrate/20200919075557_add_attachment_image_to_pics.rb:1:in `<main>'
/home/sourav/railsProjects/InstagramApp/bin/rails:9:in `<top (required)>'
/home/sourav/railsProjects/InstagramApp/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
The issue can be fixed simply by modifying the migration file, and add [6.0] beside ActiveRecord::Migration, for me it's something like this:
class AddAttachmentImageToPics < ActiveRecord::Migration[6.0]
def self.up
change_table :pictures do |t|
t.attachment :image
end
end
def self.down
remove_attachment :pics, :image
end
end
C:\Users\Admin\Desktop\Ruby\instagrameme>rails db:environment:set RAILS_ENV=development db:migrate
== 20220205102326 AddAttachmentImageToPics: migrating =========================
-- change_table(:pics)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
wrong number of arguments (given 3, expected 2)
C:/Users/Admin/Desktop/Ruby/instagrameme/db/migrate/20220205102326_add_attachment_image_to_pics.rb:4:in block in up' C:/Users/Admin/Desktop/Ruby/instagrameme/db/migrate/20220205102326_add_attachment_image_to_pics.rb:3:in up'
Caused by:
ArgumentError: wrong number of arguments (given 3, expected 2)
C:/Users/Admin/Desktop/Ruby/instagrameme/db/migrate/20220205102326_add_attachment_image_to_pics.rb:4:in block in up' C:/Users/Admin/Desktop/Ruby/instagrameme/db/migrate/20220205102326_add_attachment_image_to_pics.rb:3:in up'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Deprecation notice
Paperclip is currently undergoing deprecation in favor of ActiveStorage. Maintainers of this repository will no longer be tending to new issues. We're leaving the issues page open so Paperclip users can still see & search through old issues, and continue existing discussions if they wish.
I know this is deprecated, but I am doing a course where I have to use this gem instead of ActiveStorage or Carrierwave.
The problem is, in Rails 6.0, whenever I run
rails db:{drop,create,migrate}
I get:The issue can be fixed simply by modifying the migration file, and add
[6.0]
beside ActiveRecord::Migration, for me it's something like this:And then run:
This is a temporary fix that has to be followed every time I create migration...
The text was updated successfully, but these errors were encountered: