Forum: Ruby on Rails Validating collections

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
30bfb1d1d725a1309527edde48423848?d=identicon&s=25 B Gates (Guest)
on 2006-04-12 05:30
(Received via mailing list)
I saw this issue addressed in mid-January under the
heading 'TIP: Using field_error_proc to add style
attributes to form elements', but I didn't quite get
it.

I have a collection of objects that I want to input in
one form and validate (during update).  The suggestion
in the post I referred to above was to use something
like
[in form]
> <% for @comment in @post.comments %>
> <%= text_field 'comment[]', 'author' %>
> <%= text_field 'comment[]', 'body' %>
> <% end %>
[in controller]
>all_valid = @post.comments.all? { |c| c.valid? }
>or
>all_valid = @post.comments.inject(true) {|memo, c|
c.valid? && memo }
but I'm not sure how @post.comments gets filled.  I
mean, I get how to send @post to the view, but when I
return to the controller for validation, what is
@post?  And how does it relate to the data that was
passed in the form?

Thanks,
Brian Gates

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
This topic is locked and can not be replied to.