On 12 October 2012 22:15, Javix
<s.cambour-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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 ?
In the custom validation of the operation you can use self.client to
give you its client.
Colin
>
> class Client < AR
> has_many :operations
> end
>
> class Operation < AR
> belongs_to :client
> attr_accessible :sum
> end
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.