Skip to content

Instantly share code, notes, and snippets.

@osulyanov
Created February 18, 2013 05:05
Show Gist options
  • Save osulyanov/4975218 to your computer and use it in GitHub Desktop.
Save osulyanov/4975218 to your computer and use it in GitHub Desktop.
Dynamic routing
class CategoryConstraint
def self.matches?(request)
Category.where(alias: request.path_parameters[:categoryalias]).first
end
end
resources :categories
scope '/:categoryalias', :constraints => CategoryConstraint do
get '' => 'posts#index'
get '/:postalias' => 'posts#show'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment