Skip to content

Instantly share code, notes, and snippets.

@SweeD
Created February 7, 2012 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SweeD/1760476 to your computer and use it in GitHub Desktop.
Save SweeD/1760476 to your computer and use it in GitHub Desktop.
Routing with constraints
class NewTrohpyRoute
def self.matches?(request)
trophy_id = request.params[:trophy_id] # Not sure if you can get the params this way
return NewTrophy.where(:id => trophy_id).count > 1
end
end
class OldTrohpyRoute
def self.matches?(request)
trophy_id = request.params[:trophy_id] # Not sure if you can get the params this way
return Trophy.where(:id => trophy_id).count > 1
end
end
require 'old_trophy_route'
require 'new_trophy_route'
Rails.application.routes.draw do
constraints(OldTrophyRoute) do
resources :trophies, :controller => TrophiesController
end
constraints(NewTrophyRoute) do
resources :trophies, :controller => NewTrophiesController
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment