Skip to content

Instantly share code, notes, and snippets.

@araslanov-e
Last active December 19, 2015 04:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save araslanov-e/5895283 to your computer and use it in GitHub Desktop.
Save araslanov-e/5895283 to your computer and use it in GitHub Desktop.
# app/constraints/photo_constraint.rb
class PhotoConstraint
def initialize
@types = Photo::TYPES
end
def self.matches?(request)
@types.include?(request.path_parameters[:type])
end
end
# config/routes.rb
get 'photos/:type', to: 'photos#index', constraints: PhotoConstraint.new
@dburry
Copy link

dburry commented Jul 2, 2013

small typo: ProfileConstraint.new => PhotoConstraint.new

@araslanov-e
Copy link
Author

В) oops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment