# Single inheritance 2 models OK, but what about the controller?

**URL:** <https://www.ruby-forum.com/t/single-inheritance-2-models-ok-but-what-about-the-controller/128407>\
**Category:** Rails\
**Created:** [February 7, 2008, 12:47pm UTC](https://www.ruby-forum.com/t/single-inheritance-2-models-ok-but-what-about-the-controller/128407 "2008-02-07T12:47:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e57/32.png) [@Erwin](https://www.ruby-forum.com/u/Erwin)\
**Post date:** [February 7, 2008, 12:47pm UTC](https://www.ruby-forum.com/t/single-inheritance-2-models-ok-but-what-about-the-controller/128407/1 "2008-02-07T12:47:27Z")

</div>

Hey

I am using a single inherance table :

class User \< ActiveRecord::Base

class Member \< User

I would like to use only ONE controller

accessing GET /members.xml should be equivalent to GET /  
users.xml

should I have a member\_controller and redirect all CRUDs to the  
equivalent action in users ?

or is there any trick …

thanks  
erwin

---

<div class="post-metadata">

**Author:** ![Erwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e57/32.png) [@Erwin](https://www.ruby-forum.com/u/Erwin)\
**Post date:** [February 7, 2008, 1:47pm UTC](https://www.ruby-forum.com/t/single-inheritance-2-models-ok-but-what-about-the-controller/128407/2 "2008-02-07T13:47:31Z")

</div>

I was about to ask the same question, and saw yours at the top.

I have the same setup

table: animals

class Animal \< ActiveRecord::Base  
end

class Dog \< Animal  
end

class Cat \< Animal  
end

I just want to know how and pros and cons of using 1 controller / 1  
view for each action, or a controller and set of views for each  
subclass.

---

<div class="post-metadata">

**Author:** ![Erwin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/a88e57/32.png) [@Erwin](https://www.ruby-forum.com/u/Erwin)\
**Post date:** [February 7, 2008, 1:49pm UTC](https://www.ruby-forum.com/t/single-inheritance-2-models-ok-but-what-about-the-controller/128407/3 "2008-02-07T13:49:53Z")

</div>

You should be able to define a new members\_controller like this:

class MembersController \< UsersController; end

It should get all the methods from UsersController. Not sure if it’ll do  
the  
routing though, but I think it’s worth a shot.

On Feb 7, 2008 10:16 PM, Erwin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.
