I have written an order decorator, app/models/spree/order_decorator.rb:
module Spree
module OrderDecorator
def self.prepended(base)
base.whitelisted_ransackable_attributes += %w[synced_with_erp]
end
def update_user_was_purchased
user.update_column(:was_purchase, true) if user
end
end
end
::Spree::Order.prepend Spree::OrderDecorator if ::Spree::Order.included_modules.exclude?(Spree::OrderDecorator)
Spree::Order.state_machine.after_transition to: :complete, do: :update_user_was_purchased
When I run this code in development console:
Spree::Order.state_machine.callbacks[:after].find { |callback|
callback.instance_variable_get("@methods").include?(:update_user_was_purchased)
}
it returns the callback object, as expected.
However, when i run it in console on a production server it returns nil, and hence it does not work.