ruby on rails - Unable to override a method in spree model -
i upgrading rails , spree rails 4.2 , spree 3.1
i had overriden purchase!
method in payment
model
this how method in spree
module spree class payment < spree::base module processing def purchase! started_processing! gateway_action(source, :purchase, :complete) end end end end
this how overridden in rails 3.2
(and working till now)
spree::payment::processing.class_eval def purchase! started_processing! if source.class == spree::purchaseorder gateway_action(source, :authorize, :pend) else gateway_action(source, :purchase, :complete) end end end
but getting following error rails 4.2 , spree 3.1
/home/deepak/workspace/project/app/models/spree/payment/processing_decorator.rb:2:in `<module:spree>': superclass mismatch class payment (typeerror) /home/deepak/workspace/project/app/models/spree/payment/processing_decorator.rb:1:in `<top (required)>' /home/deepak/.rvm/gems/ruby-2.3.1/gems/zeus-0.15.10/lib/zeus/load_tracking.rb:76:in `load' /home/deepak/.rvm/gems/ruby-2.3.1/gems/zeus-0.15.10/lib/zeus/load_tracking.rb:76:in `load' /home/deepak/.rvm/gems/ruby-2.3.1/gems/zeus-0.15.10/lib/zeus/load_tracking.rb:68:in `load' /home/deepak/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `block in load' /home/deepak/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency' /home/deepak/.rvm/gems/ruby-2.3.1/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `load' /home/deepak/workspace/project/config/application.rb:16:in `block (2 levels) in <class:application>' /home/deepak/workspace/project/config/application.rb:15:in `glob' /home/deepak/workspace/project/config/application.rb:15:in `block in <class:application>'
# /initializers/spree_overrides.rb module spree class payment < spree::base module processing def purchase! started_processing! if source.class == spree::purchaseorder gateway_action(source, :authorize, :pend) else gateway_action(source, :purchase, :complete) end end end end end
having in initializer override original method defined in spree.
Comments
Post a Comment