osulyanov
2/18/2013 - 5:05 AM

Dynamic routing

Dynamic routing

  resources :categories
  scope '/:categoryalias', :constraints => CategoryConstraint do
    get '' => 'posts#index'
    get '/:postalias' => 'posts#show'
  end
class CategoryConstraint
  def self.matches?(request)
    Category.where(alias: request.path_parameters[:categoryalias]).first
  end
end