I am very confused about where to put the belongs_to and the has_one
(and other relationship identifiers). I have read the RDoc and the
agile book many times about this and I think i still see it backwards.
Let me outline my app so you have an understanding…
I have 2 tables:
Schools { id, school_name, address_id }
and
Addresses { street1, street2, city, state, zip, country }
*** this is the way that makes sense to me but it doesnt work ******
Models
school.rb
has_one :address
address.rb
belongs_to :school
View for School
<% for school in @schools %>
<% end %>
(I get an error referencing the school.address.street1)
*** this is the way that does not make sense but works ****
Models
school.rb
belongs_to :address
address.rb
has_one :school
View for School
<% for school in @schools %>
<% end %>
I could really use some help understanding how to create the
relationships, and how to access them properly in the views.