When creating named scopes in a model, is it necessary to call the model before the attribute that you are using in your query?
Example
scope :sorted, order('position ASC')
vs
scope :sorted, order('pages.position ASC')
is the latter preferred, or inline with conventions? are there benefits to either? or is it just a matter of clarity or legibility?
You will need to declare the model if the scope will be used with a join with another model, which has a field with the same name.
Say the
company has_one :contact, and theContacthas aposition. Thenwill complain (on the SQL level) that it’s unclear which of the
positionfields should be used for sorting.Otherwise it’s optional.