Two examples are not equivalent.
has_many and belongs_to work as a couple where there is a many-to-one relationship.
In the database, it will look like this:
**Students** Name Email ... **Awards** Name student_id <-- !IMPORTANT! ...
Each Student has many rewards, therefore has_many :awards Each Award 'belongs to a Student , therefore belongs_to :student
Note that belongs_to applies to a table with the student_id foreign key. It is important.
OK - so what happens when there is a one-to-one relationship?
If each student can have only one reward, then the database tables may look exactly the same, but the model will not be able to return a collection of elements.
Here we need a has_one . In this case, this applies to the Student model. What for? Since the relationship is the same in both directions, but Active Record needs to know where to find the foreign key.
If the database tables were in other ways, each Student have an award_id , then Student would belongs_to , and Award would have has_one .
Hope this is clear?
It seems a little strange that a student may "belong" to an award if you use natural language. But this is how an active language is written that is specific to registered registers.
This becomes even more unnatural when you look at the many-many relationship with has_many_and_belongs_to. There is a connection table here where the site is between your main tables, for example
students_awards student_id award_id
In this situation, neither the Students table nor the Awards have a foreign key, but both will have a has_many_and_belongs_to :other_table . Both tables can join multiple rows of the other. Each Student can have more than one Award . Each Award can be applied to many Students .
The has_one only used where there is a one-to-one relationship, and the table to which it applies has an external not .