Rails 4.0 相反する名前付きルートが定義されたときに、ArgumentError発生する部分

- Rails3.2から4に上げたらエラーが出るようになったのでコード追ってみた。

```
    [aho@korekore 4.0_app]$ rails s
    => Booting WEBrick
    => Rails 4.0.13 application starting in development on http://0.0.0.0:3000
    => Run `rails server -h` for more startup options
    => Ctrl-C to shutdown server
    Exiting
    /ahoaho/.rbenv/versions/2.2.3/gemsets/4.0rails/gems/actionpack-4.0.13/lib/action_dispatch/routing/route_set.rb:430:in `add_route': Invalid route name, already in use: 'aho_aho'  (ArgumentError)
    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:
    http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
            from /ahoaho/.rbenv/versions/2.2.3/gemsets/4.0rails/gems/actionpack-4.0.13/lib/action_dispatch/routing/mapper.rb:1484:in `add_route'
            from /ahoaho/.rbenv/versions/2.2.3/gemsets/4.0rails/gems/actionpack-4.0.13/lib/action_dispatch/routing/mapper.rb:1461:in `decomposed_match'
```
- actionpack-4.0.13/lib/action_dispatch/routing/route_set.rb
 - ここのエラーが出てるっぽい

```route_set.rb
429         if name && named_routes[name]
430           raise ArgumentError, "Invalid route name, already in use: '#{name}' \n" \
431             "You may have defined two routes with the same name using the `:as` option, or " \
432             "you may be overriding a route already defined by a resource with the same naming. " \
433             "For the latter, you can restrict the routes created with `resources` as explained here: \n" \
434             "http://guides.rubyonrails.org/routing.html#restricting-the-routes-created"
435         end

```

- デバックしてみる
 - actionpack-4.0.13/lib/action_dispatch/routing/mapper.rb
 - options[:as]でas指定した文言取ってる。@set.add_routeで#<ActionDispatch::Routing::RouteSet:…>を呼び出し

```mapper.rb
   1479:           else
   1480:             options[:as] = name_for_action(options[:as], action)
   1481:           end
   1482:
=> 1483:           mapping = Mapping.new(@set, @scope, URI.parser.escape(path), options)
   1484:           app, conditions, requirements, defaults, as, anchor = mapping.to_route
   1485:           @set.add_route(app, conditions, requirements, defaults, as, anchor)
   1486:         end
```
- routesに同じ名前のものが有った為、ArgumentErrorになる。

```route_set.rb
   426:       def add_route(app, conditions = {}, requirements = {}, defaults = {}, name = nil, anchor = true)
   427:         debugger
   428:         raise ArgumentError, "Invalid route name: '#{name}'" unless name.blank? || name.to_s.match(/^[_a-z]\w*$/i)
   429:
=> 430:         if name && named_routes[name]
   431:           raise ArgumentError, "Invalid route name, already in use: '#{name}' \n" \
   432:             "You may have defined two routes with the same name using the `:as` option, or " \
   433:             "you may be overriding a route already defined by a resource with the same naming. " \
   434:             "For the latter, you can restrict the routes created with `resources` as explained here: \n" \
:
   129:         def get(name)
=> 130:           routes[name.to_sym]
   131:         end
:
=> 431:           raise ArgumentError, "Invalid route name, already in use: '#{name}' \n" \
   432:             "You may have defined two routes with the same name using the `:as` option, or " \
   433:             "you may be overriding a route already defined by a resource with the same naming. " \
   434:             "For the latter, you can restrict the routes created with `resources` as explained here: \n" \
   435:             "http://guides.rubyonrails.org/routing.html#restricting-the-routes-created"
```

- asで同じ名前を使ってはダメ