Skip to content

Instantly share code, notes, and snippets.

@darragh
Created March 12, 2009 11:21
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 darragh/78023 to your computer and use it in GitHub Desktop.
Save darragh/78023 to your computer and use it in GitHub Desktop.
# 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