ruby on rails - Why isn't my Spree::User record updating? -


i started new project on spree 3.0.1 , have implement gift card system binds amount of store credit user when gift card claimed. given of version 3.0.1 store credits functionality has not been implemented i'm trying implement simple system myself.

i ran migration add column spree::user indicating amount of store credit have. added new step on checkout process user can choose use or of store credit available. step generates price adjustment reducing price of order. field created on spree::order store how of store credit being used on transaction.

so far has been done without trouble. real trouble comes when i'm trying update credit user has left. have code in order_decorator.rb

spree::order.state_machine.after_transition to: :complete, do: :update_user_credit  def update_user_credit   credit_used = self.credit_used   initial_credit = self.user.credit   self.user.update(credit: initial_credit - credit_used) end 

to update store credit run callback after order completed, updating credit of user. reason instruction never executed.

updating user credit console has been done. user accessible callbacks, since have used credit validations.

anyone has idea why spree::user.credit not being updated?

without seeing logs it's tough say, i'm guessing haven't whitelisted credit params. if that's case can add initializers/spree.rb

spree::permittedattributes.user_attributes << :credit 

if not, post server log update action?


Comments