Class: RoomTypeSlugConstraint
- Inherits:
-
Object
- Object
- RoomTypeSlugConstraint
- Defined in:
- lib/room_type_slug_constraint.rb
Instance Method Summary collapse
-
#matches?(request) ⇒ Boolean
Matches only when the provided slug corresponds to an existing RoomType.
Instance Method Details
#matches?(request) ⇒ Boolean
Matches only when the provided slug corresponds to an existing RoomType
3 4 5 6 7 8 9 10 11 |
# File 'lib/room_type_slug_constraint.rb', line 3 def matches?(request) slug = request.params[:room_type].to_s return false if slug.blank? RoomType.exists?([ "seo_key = :slug OR LOWER(friendly_name) = :slug OR LOWER(REPLACE(name, ' ', '-')) = :slug", { slug: slug.downcase } ]) end |