Let me start off by saying I am very much a beginner.
I currently have 2 models - Person, and address.
I am currently trying to display a person and their address on the "index" page in the person section.
I can create a person and multiple addresses all at once using the Advanced Rails Recipe, and the foreign key saves fine, but now I am trying to get the person to display with their associated address on the index page and am lost.
<% if @people -%> <script type="text/javascript"> var people = <%= @people.to_json %>; </script> <% end -%>
The above code spits out the proper string for all the people I want, however, I can't seem to figure out how to spit out their addresses as well.
def index @people = Person.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @people } end end
The above is what I have in my person controller currently, and I have no idea where to go from here to get this done. Any help would be greatly appreciated.