belongs_toin your models.
Note: one-to-one relationship does not support through associations yet.
coach=instance methods to the team which returns associated coach.
team=instance method to the coach.
team_idand index to your coaches table:
has_one. In above case
team_idis assumed to be present in
coachestable. In case its different you can specify one like this:
has_manymacros provide a rails like mapping between Objects.
postsinstance method to the user which returns an array of posts.
user=instance method to the post.
user_idand index to your posts table:
usersthat belong to many
rooms. We recommend adding a new model called
participantsto represent the many-to-many relationship.
has_manyrelationships going both ways.
through:clause to simplify accessing the many-to-many relationship: