I have a table called items
with a type
column.
This column can have one of the following values:
rock
paper
scissor
Inside my translation file:
en:
rock: Stone
paper: Wood
scissor: Weapon
How can i fetch the results and order them by the translated value using ActiveRecord?
Obviously, if I do Item.where(something: true).order('name asc')
I would get the results ordered by the value inside the database (rock
) and not the translated value (Stone
).
I am aware of some ruby methods such as sort_by
and sort
to order items with ruby, but I would like to order the results in ActiveRecord for performance reasons.