Created
March 12, 2009 11:21
-
-
Save darragh/78023 to your computer and use it in GitHub Desktop.
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
# As part of blog post "Detect clashing named routed early in rails" | |
# http://blog.peelmeagrape.net/2009/3/12/detect-clashing-named-routes-early-in-rails | |
module IGOpeople | |
module Routing | |
module BorkOnNamedRouteClash | |
def self.included(base) | |
base.alias_method_chain(:add_named_route, :checking_clash) if ['development','test'].include?(RAILS_ENV) | |
end | |
def add_named_route_with_checking_clash(name, path, options = {}) | |
raise('clashing named route: '+ name.to_s) unless named_routes[name.to_sym].nil? | |
add_named_route_without_checking_clash(name,path,options) | |
end | |
end | |
end | |
end | |
ActionController::Routing::RouteSet.send :include, IGOpeople::Routing::BorkOnNamedRouteClash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment