Emi Matchu
2667ed49ba
Now that DTI 2020 has been deployed without references to the translations tables, we can stop keeping them in sync! Next step is to drop the tables and be done with them altogether! (I have a backup of the public data for this too, as does this repo!)
23 lines
495 B
Ruby
23 lines
495 B
Ruby
class Species < ApplicationRecord
|
|
has_many :pet_types
|
|
has_many :alt_styles
|
|
|
|
scope :alphabetical, -> { order(:name) }
|
|
|
|
scope :with_body_id, -> body_id {
|
|
pt = PetType.arel_table
|
|
joins(:pet_types).where(pt[:body_id].eq(body_id)).limit(1)
|
|
}
|
|
|
|
def as_json(options={})
|
|
super({only: [:id, :name], methods: [:human_name]}.merge(options))
|
|
end
|
|
|
|
def human_name
|
|
if name
|
|
name.capitalize
|
|
else
|
|
I18n.translate('species.default_human_name')
|
|
end
|
|
end
|
|
end
|