yes I'm currently using those last railscasts methods but it's getting
pretty difficult to use the method in the edit form.


I am trying to follow an ajax method that should insert a new nested
attirubte form upon clicking a submit button in a form_remote_for.  I
put this in the create.rjs


association = :treatments
new_object =
@sample.class.reflect_on_association(association).klass.new

fields = :new_sample.fields_for(association, new_object, :child_index
=> "new_#{association}") do |builder|
      render(association.to_s.singularize + "_fields", :f => builder)
    end

page.insert_html :bottom, :sample, fields


but I don't know how I can refer to the parent object's form in order
to call field_for.  ":new_sample" doesn't work.  Any ideas?




On Jul 6, 6:36 pm, Colin Law <[email protected]> wrote:
> On 6 July 2010 17:33, Mlle <[email protected]> wrote:
>
> > How can I use ajax to add nested attributes dynamically into the form
> > of an object?
>
> > I followed the railscast 
> > :http://railscasts.com/episodes/74-complex-forms-part-2
>
> > but I'd like to use Ajax instead because the method above is sort of
> > ugly.
>
> Have you seenhttp://railscasts.com/episodes/196-nested-model-form-part-1
> and part 2?  It does not use ajax but I would not describe it as ugly.
>
> Colin

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

Reply via email to