Add method find_by_slug_or_id! to Sluggable module
Make it easier to find by slug or id for sluggable models. It will raise a 404 HTML Not found error if the resource is not found.
This commit is contained in:
committed by
Javi Martín
parent
4bd20eebf4
commit
22076dd95c
@@ -7,6 +7,10 @@ module Sluggable
|
||||
def self.find_by_slug_or_id(slug_or_id)
|
||||
find_by_slug(slug_or_id) || find_by_id(slug_or_id)
|
||||
end
|
||||
|
||||
def self.find_by_slug_or_id!(slug_or_id)
|
||||
find_by_slug(slug_or_id) || find(slug_or_id)
|
||||
end
|
||||
end
|
||||
|
||||
def generate_slug
|
||||
|
||||
Reference in New Issue
Block a user