Backfill globalize's find_by_name method
This method was removed in globalize 4, which we upgraded to for compatibility with Rails 4! Let's add back in a similar thing for now!
This commit is contained in:
parent
dc9d82ce86
commit
5f887dc8a1
2 changed files with 12 additions and 0 deletions
|
@ -14,6 +14,12 @@ class Color < ActiveRecord::Base
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
|
||||||
|
# TODO: Should we consider replacing this at call sites? This used to be
|
||||||
|
# built into the globalize gem but isn't anymore!
|
||||||
|
def self.find_by_name(name)
|
||||||
|
matching_name(name).first
|
||||||
|
end
|
||||||
|
|
||||||
def as_json(options={})
|
def as_json(options={})
|
||||||
{id: id, name: human_name, unfunny_name: unfunny_human_name, prank: prank?}
|
{id: id, name: human_name, unfunny_name: unfunny_human_name, prank: prank?}
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,12 @@ class Species < ActiveRecord::Base
|
||||||
where(st[:name].matches(sanitize_sql_like(name)))
|
where(st[:name].matches(sanitize_sql_like(name)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO: Should we consider replacing this at call sites? This used to be
|
||||||
|
# built into the globalize gem but isn't anymore!
|
||||||
|
def self.find_by_name(name)
|
||||||
|
matching_name(name).first
|
||||||
|
end
|
||||||
|
|
||||||
def as_json(options={})
|
def as_json(options={})
|
||||||
{:id => id, :name => human_name}
|
{:id => id, :name => human_name}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue