[Rails] AR validation question
What is the best way to implement a validation for a withdrawal operation? So there is an Operation and Client models.
Client has_many :operations. In case of withdrawal operation, I'd like to check if the requested sum is not greater than a Client account balance. How to link the validation in the Operation model to a specific client ?
class Client < AR
has_many :operations
end
class Operation < AR
belongs_to :client
attr_accessible :sum
end
The routes are defined so that an operation could only created in the context of a Client.
Thanks
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/9_Fv6SCrRiwJ.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home