method
add_route
Ruby on Rails latest stable (v7.1.3.2)
-
0 notes -
Class: ActionDispatch::Routing::RouteSet
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (0)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- What's this?
add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true)
public
Hide source
# File actionpack/lib/action_dispatch/routing/route_set.rb, line 426 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*$/) 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 = build_path(conditions.delete(:path_info), requirements, SEPARATORS, 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