Hi All,
Probably this has been asked numerous times, I apologize already!
Can somebody point me to a good tutorial on how Rails works with
relations?
I know about database design and normalization, I also know about
programming in general (and OOP for that matter).
Only thing I can say is that I’m following the “Four days on Rails”
tutorial by John McCreesh.
He writes on Items and Notes (for his Todo example).
The items table has a key to the note_id. However (and this in
particular I’m trying to understand), the Models which accompany the
tables (item & note) are like:
class Item class Note
belongs_to: note # nothing here really
. .
. .
end end
It only struck me that I have the feeling that “it” (belongs_to)
should be the other way around.
I’m actually looking for some page which spills out the relations or
associations within Rails, like:
1:1 relation: has_one, belongs_to in such and such way
1:many relation has_many, belongs_to in such and such way
many:many relation: already has a tutorial of it’s own! (http://
jrhicks.net)
Thanks,
Tom