rails:回形针gem的迁移问题

dffbzjpn  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(447)

我正在尝试迁移rails应用程序,但失败了。回形针宝石迁移中的问题。
我尝试使用两种方法进行迁移,但两种方法都不能正常工作:

class AddAttachmentImageToItems < ActiveRecord::Migration[6.1]
  def self.up
    add_attachment :items, :image
  end

  def self.down
    remove_attachment :items, :image
  end
end

还尝试:

class AddAttachmentImageToItems < ActiveRecord::Migration[6.1]
  def change
    add_attachment :items, :image
  end
end

赛后 rails db:migrate 显示错误:

/Users/zi/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/pry-byebug-3.8.0/lib/pry-byebug/control_d_handler.rb:5: warning: control_d_handler's arity of 2 parameters was deprecated (eval_string, pry_instance). Now it gets passed just 1 parameter (pry_instance)
== 20210713231704 AddAttachmentImageToItems: migrating ========================
-- add_attachment(:items, :image)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (given 4, expected 3)
/Users/zi/rails/stage_1/db/migrate/20210713231704_add_attachment_image_to_items.rb:3:in `up'
/Users/zi/rails/stage_1/bin/rails:5:in `<top (required)>'
/Users/zi/rails/stage_1/bin/spring:10:in `block in <top (required)>'
/Users/zi/rails/stage_1/bin/spring:7:in `<top (required)>'

Caused by:
ArgumentError: wrong number of arguments (given 4, expected 3)
/Users/zi/rails/stage_1/db/migrate/20210713231704_add_attachment_image_to_items.rb:3:in `up'
/Users/zi/rails/stage_1/bin/rails:5:in `<top (required)>'
/Users/zi/rails/stage_1/bin/spring:10:in `block in <top (required)>'
/Users/zi/rails/stage_1/bin/spring:7:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
rnmwe5a2

rnmwe5a21#

在ruby版本中发现问题,降级到2.6.8,迁移工作正常。

相关问题