I have got this answered on 
http://stackoverflow.com/questions/1521028/rails-complex-form-validations.

On Oct 6, 2:49 am, fahrio <[email protected]> wrote:
> I have a complex form for my Work model. It accepts nested attributes
> for Credits, Images and Videos. (it is a modified version of Eloy
> Duran's complex form example)
>
> I want to validate presence of at least one Credit
> I want to validate presence of at least one Image or one Video
>
> When I do (in work.rb):
> validates_presence_of :credits
> It validates properly when I try to submit the form without any
> credits but it does not validate if I remove the last credit (by
> checking a check_box that adds "_delete" to credit's attributes). It
> submits the work deleting the one and only credit leaving the work
> without any credits.
>
> If I could find a way to check if last credit is selected for deletion
> from the Work model I coult prevent the save but feels like the wrong
> way, trying to access credits attributes from the work model.
>
> Do you have any idea on how I can validate these properly?
>
> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to