darragh (owner)

Revisions

  • 39e096 Thu Mar 12 04:21:13 -0700 2009
gist: 78023 Download_button fork
public
Public Clone URL: git://gist.github.com/78023.git
detect_named_route_clashed.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 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