# {ActionController\] Default route naming

**URL:** <https://www.ruby-forum.com/t/actioncontroller-default-route-naming/169587>\
**Category:** Rails\
**Created:** [June 5, 2009, 5:27pm UTC](https://www.ruby-forum.com/t/actioncontroller-default-route-naming/169587 "2009-06-05T17:27:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [June 5, 2009, 5:27pm UTC](https://www.ruby-forum.com/t/actioncontroller-default-route-naming/169587/1 "2009-06-05T17:27:57Z")

</div>

I have discovered that if a named resources entry does not have a plural  
form then ActionController::Routing uses route\_name\_index instead.  
However, I cannot seem to find any place in the API where this is  
mentioned. Can somebody point out to me where this behaviour is  
specified?

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [June 5, 2009, 5:42pm UTC](https://www.ruby-forum.com/t/actioncontroller-default-route-naming/169587/2 "2009-06-05T17:42:56Z")

</div>

Are you talking about singular resources?

> **[rails.info](http://guides.rails.info/routing.html#singular-resources)**
>
> Ruby on Rails,Rails Tutorial,Ruby Basics,Rails 4,Bar Rails,Rail

If not, you may want to show how you’re declaring your route…

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [June 5, 2009, 6:50pm UTC](https://www.ruby-forum.com/t/actioncontroller-default-route-naming/169587/3 "2009-06-05T18:50:17Z")

</div>

Lee S. wrote:

> Are you talking about singular resources?
> 
> [http://guides.rails.info/routing.html#singular-resources](http://guides.rails.info/routing.html#singular-resources)

I am not talking about singular resources.

> If not, you may want to show how you’re declaring your route…

map.resources :forex,  
:type =\> ‘CABK’,  
:controller =\> ‘currency\_exchange\_rates’,  
:only =\> [:index, :show]

$ rake routes  
…  
forex\_index GET /forex(.:format) {:action=\>“index”,  
:controller=\>“currency\_exchange\_rates”}

```
  forex GET /forex/:id(.:format) {:action=>"show",
                                     :controller=>"currency_exchange_rates"}

```

…

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [June 5, 2009, 9:40pm UTC](https://www.ruby-forum.com/t/actioncontroller-default-route-naming/169587/4 "2009-06-05T21:40:07Z")

</div>

Looks fine to me…what are you expecting the route to be?

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [June 8, 2009, 3:49pm UTC](https://www.ruby-forum.com/t/actioncontroller-default-route-naming/169587/5 "2009-06-08T15:49:14Z")

</div>

Lee S. wrote:

> Looks fine to me…what are you expecting the route to be?

Yes, I confused myself by using both named routes and resources. That  
and I got caught by Rails inflection system as forex has no plural so  
that the index action becomes forex\_index GET, rather than forexes GET.

I ended up with this sort of thing instead:

map.forex\_by\_currency\_and\_date   
‘/forex/:currency\_code/:year/:month/:day’,  
…

map.forex\_by\_currency   
‘/forex/:currency\_code’,  
…

map.forex\_by\_date   
‘/forex/:year/:month/:day’,  
…

map.resources :forex,  
:type =\> ‘CABK’,  
:controller =\> ‘currency\_exchange\_rates’,  
:only =\> [:index, :show]

# Note that because forex has no plural form registered in inflections

# the generated index route is named forex\_index
