On Thu, 2008-09-25 at 12:11 -0700, Nathan R wrote:
> I am having this same problem, but I need to do this with ajax.....
> any ideas? I've been racking my brain on this for a few hours now and
> am losing it,
>
> On Sep 22, 6:47 am, jney <[EMAIL PROTECTED]> wrote:
> > Hi erol,
> >
> > Try this :
> >
> > <% form_for(@master_model) do |f| %>
> > <%= f.error_messages %>
> >
> > <%-fields_for('master_model[sub_model][]', SubModel.new) do |sm| -
> > %>
> > <%= sm.text_field :field1 %>
> > <%= sm.text_field :field2 %>
> > <%= sm.text_field :field3 %>
> > <%- end -%>
I find way better results with
form_remote_for([EMAIL PROTECTED], @sub_model])
in cases where I need several instances of sub model
I do something like this in the view
<% unless @master_model.sub_models.nil? %>
<%= render :partial => 'sub_model', :collection =>
@master_model.sub_models, :object => @master_model%>
<% end %>
<%= render :partial => 'new_sub_model', :object => [EMAIL PROTECTED],
@sub_model] %>
then the partials use
div_for(sub_model) so the controller can talk back ajax to each instance
of the form
the new_sub_model partial sends to create,
then create via rjs, refreshes the list of sub_models and shows a new
empty new_sub_model template
> >
> > <%-fields_for('master_model[sub_model][]', SubModel.new) do |sm| -
> > %>
> > <%= sm.text_field :field1 %>
> > <%= sm.text_field :field2 %>
> > <%= sm.text_field :field3 %>
> > <%- end -%>
> > <p>
> > <%= f.submit "Create" %>
> > </p>
> > <% end %>
> >
> > then check params format (it should be ok), then replace "form_for"
> > with "remote_form_for" and check params format,
> > "master_model[sub_model]" should be wrong
> >
> > On 22 sep, 01:29, Erol Fornoles <[EMAIL PROTECTED]> wrote:
> >
> > > On Sep 22, 1:29 am, jney <[EMAIL PROTECTED]> wrote:
> >
> > > > i just checked it again and it looks like a form_remote_for bug,
> > > > because with a non ajax form_for params are well formed,
> > > > can someone confirm it?
> >
> > > It's impossible to confirm with the little information you've given.
> > > Care to elaborate?
> --~--~---------~--~----~------------~-------~--~----~
> 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
> -~----------~----~----~----~------~----~------~--~---
>
--
Andres Paglayan
CTO, StoneSoup LLC
Ph: 505 629-4344
Mb: 505 690-2871
FWD: 65-5587
Testi. Codi. Vinci.
smime.p7s
Description: S/MIME cryptographic signature

