I am trying to do a list of people in a collection that is shown with
a partial. This part works fine. The trouble comes when I put radio
buttons with each record for which family member gets the mail sent to
that house. If the record for a person is new, the radio button
returns ID instead of the id number that doesn’t exist yet. How can I
get the id of the record after it is saved and put it in
household.hoh ? Here is part of the app. By the way, I’m still using
2.3.9 until these problems are gone.
Thanks
Bob
_people.html.erb
<%= link_to_function “Add a Person” do |page|
page.insert_html :after, “new”, :partial => ‘shared/
new_person’, :object => Person.new
end %>
HOH | Last Name | First Name | M | Sex | Month | Day | Year | <%= render :partial => 'shared/person', :locals => {:household => @household} , :collection => @household.people.sort_by(&:birthday) %>
---|
_person.html.erb
<% fields_for “household[people_attributes][]”, person do |
person_form| %>
household.rb
def after_save
person = Person.find(self.hoh) # Of course, this is 0 at
the moment. I did after_save so the
| person
record would be there to access, I just need the id of it now,
self.first_name = person.first_name
self.last_name = person.last_name
self.middle = person.middle
end