1
I want to know how to validate my model for when @model.update_attributes(params) in my controller is called to return a possible error or false that seems to be the default returned by update_attributes.
Following the logic of fat models, I thought to put the validation in the model because it would lose my controller.
The question is how to implement this in the model so that my controller only continues with @model.update_attributes(params). And return false if validation does not pass.
Validation should only happen in the update.
I tried this validate :tem_stock, :before => :update , but the object is still saved even adding an error and returning false in the tem_stock method. Until without :before => :update the object is still saved. Just to put it in context, I’m trying to avoid updating a line_item from Spree if this line_item doesn’t have the product in stock. The stock in this case does not use the default Spree but a customization.
– cassioscabral