# Reading and saving data with belongs\_to and has\_many

**URL:** <https://www.ruby-forum.com/t/reading-and-saving-data-with-belongs-to-and-has-many/111126>\
**Category:** Rails\
**Created:** [August 2, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/reading-and-saving-data-with-belongs-to-and-has-many/111126 "2007-08-02T21:25:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jack\_W\_Jennings](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ba8739/32.png) [@Jack\_W\_Jennings](https://www.ruby-forum.com/u/Jack_W_Jennings)\
**Post date:** [August 2, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/reading-and-saving-data-with-belongs-to-and-has-many/111126/1 "2007-08-02T21:25:13Z")

</div>

Hi all, I’m new to Ruby on Rails, and so I have a question that’s  
probably simple, but I can’t figure it out.

I’m trying to create several models that all belong\_to a master model,  
say “entries”, which has\_one of the others. The other tables  
(“destinations”, “people”, “entrydates”) all have the entry\_id row.

How would one reference each row that matches the entry.id in a loop  
(i.e. display the entry and the “destination”, “person”, and  
“entrydate” that matches)?

Also, how would one save the data to each of these tables in one  
form?

All of the code that I’ve written has been lengthy and ugly (and also  
doesn’t really work), and I can only imagine that there has to be a  
concise way to do this…
