Hi,

A couple of related questions...

On p334 of The Rails 3 Way there's an example that looks like this:

form_for :client, person, :url => {:action => "update"} do |f|

which it is claimed allows you to use a different name, 'client' for
person in the params hash.

I haven't been able to get this to work, however in looking at the API
documentation here: http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for

I see an example that uses a different syntax, like this:

form_for(@person, :as => :client) do |f|

which does work for me as advertised.

However I also see that the Rails 2.3.8 documentation does have an
example with the first syntax, which makes me think the API was
changed, though I haven't been able to find any explicit discussion of
this anywhere. Curiously, my experimentation finds that the original
syntax still works on fields_for.

Can someone confirm for me that the example in TR3W is wrong and that
the syntax for form_for was changed in 3.x, but not for fields_for. If
that is so, what is the rationale for using different approaches in
the two different methods?

Second question... on p337 there's an example that looks like this:

form_for "person[]" do |f|

which is intended to generate id-indexed attribute keys in the params
hash. Again, this doesn't work for me, for I think the same reason as
above. It seems like the right way to do this would to create the form
with the form_tag helper and then use

fields_for "person[]" do |f|

Again can someone please confirm for me that TR3W is wrong here.

Thanks for any help.

--
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.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 5, '12 at 10:07p
activeJan 5, '12 at 10:07p
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

MarkMT: 1 post

People

Translate

site design / logo © 2023 Grokbase