vendredi 26 novembre 2021

To upgrade Rails 5.1 migrations to Rails 6.0, I can't exchange add_attachment to what

I am upgrading ruby version from 2.5.7 to 3.0.0 So I upgrade rails version from 5.1 to 6.1 also.

After version upgrade, I tried to migrate database. Then I am facing following issues: [screenshot][1]

Here is the migrations file source:

class AddAttachmentAvatarToUsers < ActiveRecord::Migration[5.1]
  def self.up
    change_table :users do |t|
    t.attachment :avatar
  end
end

  def self.down
    remove_attachment :users, :avatar
  end
end

I am using gem 'paperclip', '~> 5.0.0'

after googling I tried with this codes.

class AddAttachmentAvatarToUsers < ActiveRecord::Migration[6.1]
  def self.up
    add_attachment :users, :avatar
  end

  def self.down
    remove_attachment :users, :avatar
  end
end

Then it causing bellow issues

[screenshot2][2]

Pls help me fix this issue. [1]: https://i.stack.imgur.com/SFNmK.png [2]: https://i.stack.imgur.com/fMHYY.png

Aucun commentaire:

Enregistrer un commentaire