Guest User

Untitled

a guest
Nov 30th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.30 KB | None | 0 0
  1. class ParamPresenceConstraint
  2.     def initialize(param_name)
  3.         @param_name = param_name
  4.     end
  5.  
  6.     def matches?(request)
  7.             request.query_parameters[@param_name].present?
  8.         end
  9. end
  10.  
  11. #routes
  12.  
  13. resources :items do
  14.     get '/', to: :show, constraint: ParamPresenceConstraint.new('id')  
  15. end
Advertisement
Add Comment
Please, Sign In to add comment