What you want to use is :accept_nested_attributes in your models

class Profile < ActiveRecord::Base

  has_many :responsibles
  accepts_nested_attributes :responsibles

end

And then you'll want to do something like this in your view

<% form_for @profile do |profile_form| %>

  <%= profile_form.label :name %>
  <%= profile_form.text_field :name %>

  <% profile_form.fields_for :responsibles do |child_form| %>

    <%= child_form.label :name %>
    <%= child_form.text_field :name %>

    <% unless child_form.object.new_record? %>
      <%= child_form.check_box '_delete' %>
      <%= child_form.label '_delete', 'Remove' %>
    <% end %>

  <% end %>

  <%= submit_tag %>
<% end %>

That's all

In order to use this, you have to ensure you're using rails 2 but I'm 
sure you are.

Here's more info
http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes

-- 
Posted via http://www.ruby-forum.com/.

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