Does this work>
<% form_for @user do |f| %>
<% f.fields_for :user_details do |user_detail| %>
<p><%= user_detail.label :given_name %></p>
<p><%= user_detail.text_field :given_name %></p>
<% user_detail.fields_for :offices do |office| %>
<p><%= office.label :office_name %></p>
<p><%= office.text_field :office_name %></p>
<%end%>
<%end%>
<p><%= f.submit ''Sign Up'' %></p>
<%end%>
Darian Shimy
--
http://www.darianshimy.com
http://twitter.com/dshimy
On Tue, Nov 24, 2009 at 2:23 AM, Abhishek shukla
<betterabhi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hello Friends,
>
> I am stucked with the nested model with through association
>
> I have
>
> class Office < AR::B
> has_many :office_user_details
> has_many :user_details, :through => :office_user_details
> accepts_nested_attributes_for :user_details
> end
>
> class UserDetail < AR::B
> has_many :office_user_details
> has_many :offices, :through => :office_user_details
> accepts_nested_attributes_for :offices
> end
>
> class OfficeUserDetail < AR::B
> belongs_to :user_details
> belongs_to :offices
> end
>
> FORM
>
> <% form_for @user do |f| %>
>
> <% f.fields_for :user_detail_attributes do |user_detail| %>
> <p><%= user_detail.label :given_name %></p>
> <p><%= user_detail.text_field :given_name %></p>
>
> <% user_detail.fields_for :offices_attributes do |office| %>
> <p><%= office.label :office_name %></p>
> <p><%= office.text_field :office_name %></p>
> <%end%>
>
> <%end%>
> <p><%= f.submit ''Sign Up'' %></p>
> <%end%>
>
>
> But getting the following error
>
> undefined method `stringify_keys'' for "Andy Inc":String
(NoMethodError)
>
> Thanks
> Abhishek
>
> --
>
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
--
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.