Created
November 16, 2009 00:07
-
-
Save agreycrane/235592 to your computer and use it in GitHub Desktop.
Links work - however, add email address link is in the wrong location
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> | |
<%= 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" %> | |
<p> | |
<%= add_email_address_link "Add an email address" %> | |
</p> | |
<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