It never fails! If you are having a problem trying to get something to
work, post something looking for help and within 15 minutes, you''ll
figure it out!
I went back and reviewed the railscast on nested forms, which used a
has_many form and answered my 3rd question = you have to have an
array.
In my new action in the Groups controller I just added:
1.times {@group.users.build}
and changed my fields_for to:
<%= f.fields_for :users do |user_fields| %>
and everything worked! Singular - plural is something you just always
have to think of.
Steve
On May 27, 6:09 am, AppleII717 <sa...-ee4meeAH724@public.gmane.org>
wrote:> Not sure if this the best place to look for rails 3.0 beta 3 help, but
> I''ll give it a try.
>
> I can''t seem to get nested forms to work in the beta - close but
no
> workie!
>
> I used an approach similar to one I used in a 2.3 application to
> update a user record from a profile record (citizen has_one :user,
> accepts_nested_attributes_for :user ) except I''m try to create a
user
> record from a has_many relation (initial registration for a new group/
> subdomain)
>
> class Group < ActiveRecord::Base
> has_many :users
> accepts_nested_attributes_for :users, :allow_destroy => true
> end
>
> I have my nested form set up with:
>
> <%= f.fields_for :user, @user do |user_fields| %>
> ...
>
> The form builds, but not the same has in 2.3
>
> For instance, in 2.3 I''ll get:
>
> name="group[user_attributes][password_confirmation]"
>
> in 3 I''ll get:
>
> name="group[user][password_confirmation]"
>
> submitting the form will generate an error with unknown variable
> "user"
>
> Has anyone gotten nested forms to work in 3?
> Am I missing some new approach that sets [group][user_attributes]
> instead of [group] [user]?
> Do you have to do something different with a nested has_many relation?
> (since I assume it would normally be an array)
>
> Steve Alex
--
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@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.