impress/app/models/species.rb
Matchu eaf875c6c7 zone, species, color alphabetical by the current locale
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.
2013-01-27 00:25:52 -06:00

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