# Stupid ruby controller question

**URL:** <https://www.ruby-forum.com/t/stupid-ruby-controller-question/90054>\
**Category:** Engines Development\
**Created:** [January 5, 2006, 10:56am UTC](https://www.ruby-forum.com/t/stupid-ruby-controller-question/90054 "2006-01-05T10:56:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![seth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@seth](https://www.ruby-forum.com/u/seth)\
**Post date:** [January 5, 2006, 10:56am UTC](https://www.ruby-forum.com/t/stupid-ruby-controller-question/90054/1 "2006-01-05T10:56:25Z")

</div>

Thanks for all the help so far guys…here’s another one for the smart  
engine devs…

Let’s say I have a MainController in my engine…and it has 4 actions  
inside there.

Now let’s say I want to inherit that MainController in my regular  
application, and override one of the actions…

How would I go about doing that? It seems when I place MainController in  
my application it overrides the one in my engine folder by default.

What’s the appropriate way to do this? Mixins? Inheritance?

---

<div class="post-metadata">

**Author:** ![seth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@seth](https://www.ruby-forum.com/u/seth)\
**Post date:** [January 5, 2006, 11:08am UTC](https://www.ruby-forum.com/t/stupid-ruby-controller-question/90054/2 "2006-01-05T11:08:38Z")

</div>

(this post is more suitable for engine-users btw - engine-developers  
is more for patches to the Engines plugin… but anyway… 🙂

If you have something like this in your engine:

RAILS\_ROOT/  
vendor/  
plugins/  
my\_engine/  
app/  
controllers/  
main\_controller.rb  
(with the contents:)  
class MainController \< ApplicationController  
def method1() puts “hello” end  
def method2() puts “ruby” end  
def method3() puts “rocketh” end  
end

… if you just wanted to change the behaviour of, say,  
MainController#method3, you should only need the following:

RAILS\_ROOT/  
app/  
controllers/  
main\_controller.rb  
(containing:)  
class MainController \< ApplicationController  
def method3() puts “like, y’know, totally rules” end  
end

Any methods defined in corresponding controllers of your main /app  
directory will override those in the engine. Is this what you’ve done?

- james

---

<div class="post-metadata">

**Author:** ![seth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@seth](https://www.ruby-forum.com/u/seth)\
**Post date:** [January 5, 2006, 9:43pm UTC](https://www.ruby-forum.com/t/stupid-ruby-controller-question/90054/3 "2006-01-05T21:43:47Z")

</div>

Sorry for the off-topic then…

What you describe is exactly what I’m trying…well with a little twist.  
It’s not the MainController, its one of my controllers thats a subclass.

* * *

## RAILS\_ROOT/vendor/plugins/my\_engine/app/controllers/admin/orders\_controller.rb

class Admin::OrdersController \< Admin::BaseController  
def index  
…do something  
end

def show  
…  
end

def …

end  
end

* * *

## RAILS\_ROOT/app/controllers/admin/orders\_controller.rb

class Admin::OrdersController \< Admin::BaseController  
def ship\_orders  
…do something  
end  
end

What’s going on is that when I try to hit the index action defined in my  
engine, Rails says it doesn’t exist.

“Unknown action - No action responded to index”

Could subclassing my Admin::BaseController be causing the problem? I’m  
guessing maybe engines aren’t setup to deal with this?

---

<div class="post-metadata">

**Author:** ![seth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@seth](https://www.ruby-forum.com/u/seth)\
**Post date:** [January 6, 2006, 11:44am UTC](https://www.ruby-forum.com/t/stupid-ruby-controller-question/90054/4 "2006-01-06T11:44:11Z")

</div>

This is a bug - expect a new release of the Engines plugin in a few  
hours… Thanks! 🙂

- james

---

<div class="post-metadata">

**Author:** ![seth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@seth](https://www.ruby-forum.com/u/seth)\
**Post date:** [January 12, 2006, 12:16pm UTC](https://www.ruby-forum.com/t/stupid-ruby-controller-question/90054/5 "2006-01-12T12:16:37Z")

</div>

The latest release of the Engines plugin should solve this - is it  
working for you?

- james

---------- Forwarded message ----------  
From: James A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Date: Jan 6, 2006 10:44 AM  
Subject: Re: [Engine-developers] Stupid ruby controller question  
To: removed\_email\_address@domain.invalid

This is a bug - expect a new release of the Engines plugin in a few  
hours… Thanks! 🙂

- james

---

<div class="post-metadata">

**Author:** ![seth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@seth](https://www.ruby-forum.com/u/seth)\
**Post date:** [January 13, 2006, 12:13am UTC](https://www.ruby-forum.com/t/stupid-ruby-controller-question/90054/6 "2006-01-13T00:13:24Z")

</div>

James A. wrote:

> The latest release of the Engines plugin should solve this - is it  
> working for you?
> 
> - james

Definitely. Just deployed my production app to Dreamhost about an hour  
ago.

---

<div class="post-metadata">

**Author:** ![seth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@seth](https://www.ruby-forum.com/u/seth)\
**Post date:** [January 13, 2006, 12:20am UTC](https://www.ruby-forum.com/t/stupid-ruby-controller-question/90054/7 "2006-01-13T00:20:47Z")

</div>

Excellent. URL us so we can see it!

- james

---

<div class="post-metadata">

**Author:** ![seth](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f14d63/32.png) [@seth](https://www.ruby-forum.com/u/seth)\
**Post date:** [January 14, 2006, 1:18am UTC](https://www.ruby-forum.com/t/stupid-ruby-controller-question/90054/8 "2006-01-14T01:18:39Z")

</div>

James A. wrote:

> Excellent. URL us so we can see it!
> 
> - james

I didn’t design it, so I’m not really “proud” of it per say…That and  
Dreamhost is extremely slow.

But I will plug 2 of my other sites that are running on the same engine  
code at the moment (which I designed from top to bottom)

> **[Skunk Studios® | We Stink. Our Games Don't](http://games.skunkstudios.com)**
>
> Skunk Studios® provides casual games for all to enjoy.

> **[Baby Gender Selection - Safe and Effective - Conceive a boy or girl :...](http://www.genselect.com)**
>
> Effective gender selection safe and natural. Choose the sex of your baby, boy or girl. Developed by doctors, clinically proven, patented. Over 96% success rate, used by thousands.
