【发布时间】:2020-03-27 07:34:00
【问题描述】:
我是 Rails 5/Spree 4 的新手,但我无法让回调在我的模型中工作。我想在 Spree 中创建产品后运行一些方法,但我不明白 included do 这对我来说是全新的东西。
型号:app/models/spree/product_decorator.rb
require 'active_support/concern'
module Spree
module ProductDecorator
extend ActiveSupport::Concern
included do
after_create :assign_prototype
end
def assign_prototype
binding.pry
end
end
end
我假设我忽略了一些愚蠢的事情,但我已经搞砸了一个小时。为什么这里不能识别after_create 方法?
【问题讨论】:
-
你有没有像
include Spree::ProductDecorator一样把这个模块加入到模型中
标签: ruby-on-rails spree