# Action alias

**URL:** <https://www.ruby-forum.com/t/action-alias/120473>\
**Category:** Deployment\
**Created:** [November 17, 2007, 9:29am UTC](https://www.ruby-forum.com/t/action-alias/120473 "2007-11-17T09:29:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cujigar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/2acd7d/32.png) [@cujigar](https://www.ruby-forum.com/u/cujigar)\
**Post date:** [November 17, 2007, 9:29am UTC](https://www.ruby-forum.com/t/action-alias/120473/1 "2007-11-17T09:29:26Z")

</div>

This is my current ActionController code.

def index  
list  
render :action =\> ‘list’  
end

def list  
end

I wished this would work

alias index list

def list  
end

But the problem is rails tries to render index.rhtml, instead of  
list.rhtml when index action is invoked.

I want to be able write something like this

action\_alias index list

which would add a method index to the class programatically.

please advise

---

<div class="post-metadata">

**Author:** ![cujigar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/2acd7d/32.png) [@cujigar](https://www.ruby-forum.com/u/cujigar)\
**Post date:** [November 17, 2007, 5:38pm UTC](https://www.ruby-forum.com/t/action-alias/120473/2 "2007-11-17T17:38:52Z")

</div>

Why don’t you make that action you are aliasing to, render the  
template you want it to render.

render :template =\> “somedir/somefile”

On Nov 17, 3:29 am, Jigar G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![cujigar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/2acd7d/32.png) [@cujigar](https://www.ruby-forum.com/u/cujigar)\
**Post date:** [November 17, 2007, 9:49pm UTC](https://www.ruby-forum.com/t/action-alias/120473/3 "2007-11-17T21:49:13Z")

</div>

dusty wrote:

> Why don’t you make that action you are aliasing to, render the  
> template you want it to render.
> 
> render :template =\> “somedir/somefile”
> 
> On Nov 17, 3:29 am, Jigar G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

As I have shown in the example, I have that as my current code, I was  
looking to make it more concise.

---

<div class="post-metadata">

**Author:** ![cujigar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/2acd7d/32.png) [@cujigar](https://www.ruby-forum.com/u/cujigar)\
**Post date:** [November 19, 2007, 10:45am UTC](https://www.ruby-forum.com/t/action-alias/120473/4 "2007-11-19T10:45:21Z")

</div>

Jigar G. escribiÃ³:

> I want to be able write something like this
> 
> action\_alias index list
> 
> which would add a method index to the class programatically.
> 
> please advise

Maybe you can play with routes.rb  
Regards

–  
Rafael Garcia Ortega

---

<div class="post-metadata">

**Author:** ![cujigar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/2acd7d/32.png) [@cujigar](https://www.ruby-forum.com/u/cujigar)\
**Post date:** [November 26, 2007, 12:15am UTC](https://www.ruby-forum.com/t/action-alias/120473/5 "2007-11-26T00:15:57Z")

</div>

if you really just want one of those instead of two,  
if you do it the RESTful way: get rid of the list action,  
and stick with just the index action.

daniel

On Nov 17, 10:29 am, Jigar G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
