# Overloading controller

**URL:** <https://www.ruby-forum.com/t/overloading-controller/58464>\
**Category:** Engines\
**Created:** [April 21, 2006, 10:34pm UTC](https://www.ruby-forum.com/t/overloading-controller/58464 "2006-04-21T22:34:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prplehaze](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e68b1a/32.png) [@prplehaze](https://www.ruby-forum.com/u/prplehaze)\
**Post date:** [April 21, 2006, 10:34pm UTC](https://www.ruby-forum.com/t/overloading-controller/58464/1 "2006-04-21T22:34:02Z")

</div>

Hi,  
The mailing list archives appear to be down currently, so I wasn’t  
able to search them first.

What is the best practice for overloading an engine controller method?  
I have Login Engine and User Engine installed. For example, I want  
to override signup in user to show a different warning message than  
“you need to login” (which I can accomplish by removing the guest  
permission from the signup controller). Right now, I thought of one  
way to do it:

1. Allow the Guest role to access the signup method.

2. Alias the existing signup method to open\_signup:  
alias\_method :open\_signup, :signup

3. Override the signup method to look something like this:  
def signup

The problem with this is that I now need an open\_signup.rhtml  
file…which would just end up being the same rhtml as signup.rhtml in  
the LoginEngine!

It seems like I’m missing something here.

Thanks in advance for the help.

- Sean

---

<div class="post-metadata">

**Author:** ![prplehaze](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e68b1a/32.png) [@prplehaze](https://www.ruby-forum.com/u/prplehaze)\
**Post date:** [April 22, 2006, 3:49pm UTC](https://www.ruby-forum.com/t/overloading-controller/58464/2 "2006-04-22T15:49:55Z")

</div>

On 21 Apr 2006, at 21:31, prplehaze wrote:

> What is the best practice for overloading an engine controller method?

Create a controller in your OWN app/controllers directory called  
user\_controller.rb like this:

class UserController \< ApplicationController  
def signup  
# your code goes here  
end  
end

and your method will over-ride anything in /vendor/plugins

You only need to put in the methods you wish to over-ride, and  
remember your method will replace the existing one, so you probably  
want to start with copying/pasting the existing method code and then  
adapting it if you only want to make small changes.

> 1. Allow the Guest role to access the signup method.

You need that. If you don’t, nobody will be able to ever signup.

> 1. Alias the existing signup method to open\_signup:  
> alias\_method :open\_signup, :signup

You really don’t need to do that. Just create a signup method in your  
own controller that does things

> It seems like I’m missing something here.

What I’ve described above is actually mentioned in the Engines plugin  
README, so I’d suggest you go read that, then the readme for  
login\_engine and user\_engine and then you’ll know what you can get  
away with.

–  
Paul R.
