Created
February 7, 2012 16:13
-
-
Save SweeD/1760476 to your computer and use it in GitHub Desktop.
Routing with constraints
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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