I have three fields_for inside a form_tag.
http://pastie.org/218918
Two of them, correspond to the same model, :customer, (the two
objects, billing_customer and shipping_customer have been built in the
controller method). When I submit the form, the parameters only
include one of the two fields_for methods and it comes through as the
model name, not the object name:
"customer"=>{...}
I know there is a way to use two fields_for sections that correspond
to the same model... what am I doing wrong here?
-Nik
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Nik can you update mentioned URL with field names as well
try using following:
<% fields_for :shipping_customer do |sc| %>
	<%= sc.text_field%>
        <% end %>
        <% fields_for :billing do |bi| %>
	...<%= b.text_field%>
        <% end %> <!-- end billing_fields -->
	<% fields_for :billing_customer do |bc| %>
	....<%= bc.text_field%>
	<% end %>
MOdel:
ShippingCustomer.new(params[:shipping_customer])
Billing.new(params[:billing)
ShippingCustomer.new(params[:billing_customer)
I am using something like this and it is working for me.
let me know
Ajit
On Jun 20, 12:36 pm, Nik B
<nikbau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have three fields_for inside a form_tag.
>
> http://pastie.org/218918
>
> Two of them, correspond to the same model, :customer, (the two
> objects, billing_customer and shipping_customer have been built in the
> controller method). When I submit the form, the parameters only
> include one of the two fields_for methods and it comes through as the
> model name, not the object name:
>
> "customer"=>{...}
>
> I know there is a way to use two fields_for sections that correspond
> to the same model... what am I doing wrong here?
>
> -Nik
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Just what I needed. Many thanks, Ajit. On Jun 20, 11:40 am, Ajit <ajitscor...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Nik can you update mentioned URL with field names as well > > try using following: > <% fields_for :shipping_customer do |sc| %> > <%= sc.text_field%> > <% end %> > > <% fields_for :billing do |bi| %> > ...<%= b.text_field%> > <% end %> <!-- end billing_fields --> > > <% fields_for :billing_customer do |bc| %> > ....<%= bc.text_field%> > <% end %> > > MOdel: > > ShippingCustomer.new(params[:shipping_customer]) > Billing.new(params[:billing) > ShippingCustomer.new(params[:billing_customer) > > I am using something like this and it is working for me. > > let me know > > Ajit > > On Jun 20, 12:36 pm, Nik B <nikbau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have three fields_for inside a form_tag. > > >http://pastie.org/218918 > > > Two of them, correspond to the same model, :customer, (the two > > objects, billing_customer and shipping_customer have been built in the > > controller method). When I submit the form, the parameters only > > include one of the two fields_for methods and it comes through as the > > model name, not the object name: > > > "customer"=>{...} > > > I know there is a way to use two fields_for sections that correspond > > to the same model... what am I doing wrong here? > > > -Nik--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---