考虑一个A类的基本结构有很多B。现在在克隆A对象时,我想跳过对象B的回调。怎么做?我们通常使用 attr_accessor 执行此操作,但我也无法执行此操作。
https://github.com/amoeba-rb/amoeba/issues/17
这个问题从很久以前就打开了。
class File < ApplicationRecord
amoeba do
enable
include_association :attachments
end
has_many :attachments
end
class Attachment < ApplicationRecord
attr_accessor :skip_processing
amoeba do
enable
# This is wrong
set :skip_processing => true
end
belongs_to :file
after_commit :process_attachment, on: :create, unless: :skip_processing
end
在变形虫块中使用 attr_accessor 时出现了一些错误,我认为我们只能使用 DB 值。有什么解决办法吗?