module ActionDispatch module Routing class RouteSet #:nodoc: def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true) raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i) forbidden_paths = [ ::File.join(Gem.loaded_specs['scrivito_sdk'].full_gem_path, "config/routes.rb"), ::File.join(Gem.loaded_specs['scrivito_sdk'].full_gem_path, "config/precedence_routes.rb"), ::File.join(Gem.loaded_specs['infopark_fiona_connector'].full_gem_path, "config/cms_routes.rb") ] if caller.any? {|path| forbidden_paths.any? {|fp| path.include?(fp) } } return # bad dog scrivito/fiona_connector, bad dog! no cms_routes for you end if name && named_routes[name] raise ArgumentError, "Invalid route name, already in use: '#{name}' \n" \ "You may have defined two routes with the same name using the `:as` option, or " \ "you may be overriding a route already defined by a resource with the same naming. " \ "For the latter, you can restrict the routes created with `resources` as explained here: \n" \ "http://guides.rubyonrails.org/routing.html#restricting-the-routes-created" end path = conditions.delete :path_info ast = conditions.delete :parsed_path_info path = build_path(path, ast, requirements, anchor) conditions = build_conditions(conditions, path.names.map { |x| x.to_sym }) route = @set.add_route(app, path, conditions, defaults, name) named_routes[name] = route if name route end end end end