12 行
416 B
Ruby
12 行
416 B
Ruby
class Script < ApplicationRecord
|
|
has_many :locales, foreign_key: :script_code, primary_key: :code
|
|
|
|
# Canonical keys come first so reads and plucks retain ISO 15924 spelling.
|
|
# Legacy keys preserve the existing enum predicates, scopes and queries.
|
|
enum :code, { 'Jpan' => 'Jpan', 'Kana' => 'Kana', jpan: 'Jpan', kana: 'Kana' }
|
|
|
|
def code= value
|
|
super(self.class.codes.fetch(value.to_s, value))
|
|
end
|
|
end
|