Created
November 15, 2009 23:59
-
-
Save agreycrane/235578 to your computer and use it in GitHub Desktop.
Broken - Combines both links in one href
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% form_for @person do |f| -%> | |
<p> | |
First Name: <%= f.text_field :first_name %> | |
</p> | |
<p> | |
Last Name: <%= f.text_field :last_name %> | |
</p> | |
<p> | |
Company: <%= f.text_field :company %> | |
</p> | |
<div id="email_addresses"> | |
<%= render :partial => 'email_address_form', :collection => @person.email_addresses %> | |
</div> | |
<p> | |
<%= add_email_address_link "Add an email address" %> | |
</p> | |
<p> | |
<%= f.submit "Submit" %> | |
</p> | |
<% end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= add_person_link "New Person" %> | |
<div id="people"> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PeopleHelper | |
def add_email_address_link(name) | |
link_to_function name do |page| | |
page.insert_html :top, :email_addresses, :partial => 'email_address_form', :object => EmailAddress.new | |
end | |
end | |
def add_person_link(name) | |
link_to_function name do |page| | |
page.insert_html :top, :people, :partial => 'person_form', :object => Person.new | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment