ruby on rails - Spree::Shipment state machine -


i'm trying use shipment "ready" state callback custom method, in "shipment_decorator.rb" have this

spree::shipment.class_eval   spree::shipment.state_machine.after_transition to: :ready, do: :create_external_shipment    def create_external_shipment     'my custom method'   end end 

the problem reason don't understand, spree not doing custom method.

i try state_machine.after_transition to: :ready, do: :create_external_shipment, self.state_machine.after_transition to: :ready, do: :create_external_shipment, copy paste entire model make full override , still not working.

do missing here?

i'm using spree 2.2 stable , don't have extensions adding behavior shipments

i'm pretty sure shipment state machine not being used in case.

your shipment being set ready this:

https://github.com/spree/spree/blob/v2.2.1/core/app/models/spree/shipment.rb#l223-l226

which called here:

https://github.com/spree/spree/blob/v2.2.1/core/app/models/spree/order_updater.rb#l21

which coming from:

https://github.com/spree/spree/blob/v2.2.1/core/app/models/spree/payment.rb#l24

because happening through activerecord callbacks, state machine not being invoked , shipment being set ready through other means , not triggering state machine event. you'll need find alternate place hook logic in.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -