I don’t think you want your model validating another models attributes like 
this but to answer the question you could put in a return statement. 
return errors.add(…)


> On Apr 25, 2015, at 8:47 AM, Gm <[email protected]> wrote:
> 
> Hi,
> 
> I'm trying to validate an array attribute "accepts_nested_attributes_for".
> I've created a method like this:
> 
>   validate :validate_nested_attributes
> 
>   def validate_nested_attributes
>     items.each do |item|
>      errors.add("item_#{item.number}_#{self.id}", "error on #{item.number}") 
> if item.value.blank?
>     end
>   end
> 
> But this method validates all items of array.
> I just want do display erros one at a time instead displaying all erros 
> inside the form.
> 
> Tips on how to solve this problem ?
> 
> Thanks.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/29e4caea-637f-4072-9c06-cb630361f268%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/rubyonrails-talk/29e4caea-637f-4072-9c06-cb630361f268%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/B70B0D9D-0E11-4B0D-A651-785DF6EF67DA%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to