Matchu
eaf875c6c7
We were joining to the translations table to sort records alphabetically, but then it sorted by *all* of the translations in some strange way. Now use with_translations to restrict the join to the current locale.
13 lines
290 B
Ruby
13 lines
290 B
Ruby
class Species < ActiveRecord::Base
|
|
translates :name
|
|
|
|
scope :alphabetical, lambda { with_translations(I18n.locale).order(Species::Translation.arel_table[:name]) }
|
|
|
|
def as_json(options={})
|
|
{:id => id, :name => human_name}
|
|
end
|
|
|
|
def human_name
|
|
name.capitalize
|
|
end
|
|
end
|