# How can I change member action names on routes?

**URL:** <https://www.ruby-forum.com/t/how-can-i-change-member-action-names-on-routes/172955>\
**Category:** Rails\
**Created:** [July 30, 2009, 3:23pm UTC](https://www.ruby-forum.com/t/how-can-i-change-member-action-names-on-routes/172955 "2009-07-30T15:23:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [July 30, 2009, 3:23pm UTC](https://www.ruby-forum.com/t/how-can-i-change-member-action-names-on-routes/172955/1 "2009-07-30T15:23:55Z")

</div>

I have some controllers with member/collection actions. I want to change  
the name of those actions on the routes, so I can translate the action  
“/search” to German, for example. How can I do it? I will appreciate any  
help.

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [July 30, 2009, 3:31pm UTC](https://www.ruby-forum.com/t/how-can-i-change-member-action-names-on-routes/172955/2 "2009-07-30T15:31:10Z")

</div>

Currently I am using Rails 2.2.2 and I shoul not change it.

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [July 30, 2009, 3:35pm UTC](https://www.ruby-forum.com/t/how-can-i-change-member-action-names-on-routes/172955/3 "2009-07-30T15:35:36Z")

</div>

map.resource :search, :controller =\> “search\_controller”

map.suche “suche”, :controller =\> “search\_controller”, :action =\>  
“new”

Is that what you’re looking for?

Gavin

> **[Ruby on Rails tips & Tutorials](https://handyrailstips.com/)**
>
> Ruby on Rails tips and tutorials

On Jul 30, 2:23 pm, John S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [July 30, 2009, 3:39pm UTC](https://www.ruby-forum.com/t/how-can-i-change-member-action-names-on-routes/172955/4 "2009-07-30T15:39:37Z")

</div>

Gavin M. wrote:

> map.resource :search, :controller =\> “search\_controller”
> 
> map.suche “suche”, :controller =\> “search\_controller”, :action =\>  
> “new”
> 
> Is that what you’re looking for?
> 
> Gavin
> 
> [http://handyrailstips.com](http://handyrailstips.com)
> 
> On Jul 30, 2:23ï¿½pm, John S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Thanks,

what I want is to get the same url when I wrtie:  
[http://localhost:3000/articles/search](http://localhost:3000/articles/search) and  
[http://localhost:3000/articles/suchen](http://localhost:3000/articles/suchen)

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [July 30, 2009, 4:41pm UTC](https://www.ruby-forum.com/t/how-can-i-change-member-action-names-on-routes/172955/5 "2009-07-30T16:41:46Z")

</div>

Sorry - there was a typo in my first example:  
:controller =\> “search” - not :controller =\> “search\_controller”

using  
map.search “search”, :controller =\> “search”, :action =\> “new”  
map.suche “suche”, :controller =\> “search”, :action =\> “new”

should mean that both /suchen and /search route to the new search  
action

I think you may have to explicitly state the relative path in your  
links though,  
like:  
\<%= link\_to “suchen”, “/suchen” %\>  
and  
\<%= link\_to “search”, “/search” %\>

or if you’re using locales:  
\<%= link\_to t(‘search.name’), “/#{t ‘search.name’}” %\>

hope that helps?

Gavin

> **[Ruby on Rails tips & Tutorials](https://handyrailstips.com/)**
>
> Ruby on Rails tips and tutorials

On Jul 30, 2:53 pm, John S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [July 31, 2009, 9:02am UTC](https://www.ruby-forum.com/t/how-can-i-change-member-action-names-on-routes/172955/6 "2009-07-31T09:02:08Z")

</div>

Gavin M. wrote:

> Sorry - there was a typo in my first example:  
> :controller =\> “search” - not :controller =\> “search\_controller”
> 
> using  
> map.search “search”, :controller =\> “search”, :action =\> “new”  
> map.suche “suche”, :controller =\> “search”, :action =\> “new”
> 
> should mean that both /suchen and /search route to the new search  
> action
> 
> I think you may have to explicitly state the relative path in your  
> links though,  
> like:  
> \<%= link\_to “suchen”, “/suchen” %\>  
> and  
> \<%= link\_to “search”, “/search” %\>
> 
> or if you’re using locales:  
> \<%= link\_to t(‘search.name’), “/#{t ‘search.name’}” %\>
> 
> hope that helps?
> 
> Gavin
> 
> [http://handyrailstips.com](http://handyrailstips.com)
> 
> On Jul 30, 2:53ï¿½pm, John S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Thanks for the help,

I was looking for something like :as, used to change controller\_name on  
routes, but for collection and member actions. Any ideas?

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [July 30, 2009, 3:53pm UTC](https://www.ruby-forum.com/t/how-can-i-change-member-action-names-on-routes/172955/7 "2009-07-30T15:53:41Z")

</div>

I would like to cotinue using REST search\_articles\_path
