# A better way to alias methods

**URL:** <https://www.ruby-forum.com/t/a-better-way-to-alias-methods/80125>\
**Category:** Rails\
**Created:** [March 12, 2006, 7:28pm UTC](https://www.ruby-forum.com/t/a-better-way-to-alias-methods/80125 "2006-03-12T19:28:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_Daggett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@M\_Daggett](https://www.ruby-forum.com/u/M_Daggett)\
**Post date:** [March 12, 2006, 7:28pm UTC](https://www.ruby-forum.com/t/a-better-way-to-alias-methods/80125/1 "2006-03-12T19:28:59Z")

</div>

Hi is there a better way to accomplish this task?

class PortfolioController \< ProjectController  
layout ‘portfolio’

```
def boing
    redirect_to :action=>:index
end

alias_method :new , :boing
alias_method :destroy , :boing
alias_method :edit , :boing
alias_method :update , :boing

```

end

My portfolio controller implements view only control of the project  
controller therefore I want to prevent the user from poking around for  
sensitive methods inside the project controller.  
This is my current implementation, but it doesn’t feel very DRY.  
Thanks,  
Mark

---

<div class="post-metadata">

**Author:** ![M\_Daggett](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@M\_Daggett](https://www.ruby-forum.com/u/M_Daggett)\
**Post date:** [March 12, 2006, 7:38pm UTC](https://www.ruby-forum.com/t/a-better-way-to-alias-methods/80125/2 "2006-03-12T19:38:22Z")

</div>

On 3/12/06, M Daggett [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> alias_method :edit , :boing
> alias_method :update , :boing
> 
> ```
> 
> end
> 
> My portfolio controller implements view only control of the project  
> controller therefore I want to prevent the user from poking around for  
> sensitive methods inside the project controller.  
> This is my current implementation, but it doesn’t feel very DRY.  
> Thanks,  
> Mark

If that’s the only method you want to expose, you could define a route  
that always calls that action when that controller is accessed.
