是否可以在关注点中使用 Amoeba 宝石?目前,当我尝试在关注中运行它时出现此错误:
undefined method `amoeba' for Amoeba:Module
相同的代码在实际模型中运行良好,但我想干掉它,因为它在我的两个模型之间非常相似......这是关注点的样子:
module Amoeba
extend ActiveSupport::Concern
amoeba do
enable
customize(lambda { |original, clone|
clone.uid = SecureRandom.hex(2)
clone.activities = []
if original.class.name == "Widget"
clone.bookings = []
end
if orignal.class.name == "Flotsam"
clone.remaining = 100
if original.expiration.past?
clone.expiration = Date.today + 5.years
end
end
if original.icon.present?
clone.icon = original.icon
end
if original.pdf.present?
clone.pdf = original.pdf
end
})
end