Method: ActionDispatch::Routing::RouteSet::NamedRouteCollection#add

Defined in:
lib/action_dispatch/routing/route_set.rb

#add(name, route) ⇒ Object Also known as: []=



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/action_dispatch/routing/route_set.rb', line 120

def add(name, route)
  key       = name.to_sym
  path_name = :"#{name}_path"
  url_name  = :"#{name}_url"

  if routes.key? key
    @path_helpers_module.undef_method path_name
    @url_helpers_module.undef_method url_name
  end
  routes[key] = route

  helper = UrlHelper.create(route, route.defaults, name)
  define_url_helper @path_helpers_module, path_name, helper, PATH
  define_url_helper @url_helpers_module, url_name, helper, UNKNOWN

  @path_helpers << path_name
  @url_helpers << url_name
end