In most other ORM’s, in other frameworks, it is common to change those relationships using the entire object and not just setting the foreign key relationship with a primary key of a parent object. Clearly, rails has decided to go down that same avenue and it makes sense.
A proper framework should result in identically performing SQL whether you were specific in .where shelf_id: = shelf.id
or
.where shelf:=shelf
In the second case, the framework would understand that the primary key of shelf is ‘id’ and only utilize that one column in the query.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In most other ORM’s, in other frameworks, it is common to change those relationships using the entire object and not just setting the foreign key relationship with a primary key of a parent object. Clearly, rails has decided to go down that same avenue and it makes sense.
A proper framework should result in identically performing SQL whether you were specific in .where shelf_id: = shelf.id
or
.where shelf:=shelf
In the second case, the framework would understand that the primary key of shelf is ‘id’ and only utilize that one column in the query.