Skip to content

Instantly share code, notes, and snippets.

@burke
Created February 22, 2009 07:26
Show Gist options
  • Save burke/68385 to your computer and use it in GitHub Desktop.
Save burke/68385 to your computer and use it in GitHub Desktop.
# teams/new.html.haml
-form_for([@team]) do |f|
= link_to_function 'Add a Member' { |page| page.insert_html :bottom, :members, :partial => 'member', :object => Member.new }
= f.submit
# teams/_member.html.haml
- fields_for 'team[member_attributes][]', member do |f|
= f.datetime_select :arrival
# teams_controller.rb
def create
@team = Team.new(params[:team])
@members = @team.members
end
# models/team.rb
def member_attributes=(attributes)
attributes.each do |a|
members.build(a)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment