# Categories and admin/categories - different controllers and

**URL:** <https://www.ruby-forum.com/t/categories-and-admin-categories-different-controllers-and/66416>\
**Category:** Rails\
**Created:** [February 13, 2006, 6:27am UTC](https://www.ruby-forum.com/t/categories-and-admin-categories-different-controllers-and/66416 "2006-02-13T06:27:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![csn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@csn](https://www.ruby-forum.com/u/csn)\
**Post date:** [February 13, 2006, 6:27am UTC](https://www.ruby-forum.com/t/categories-and-admin-categories-different-controllers-and/66416/1 "2006-02-13T06:27:56Z")

</div>

Is there some way to have these two sets of URLs use  
totally different controllers and templates?

categories/list  
categories/show/1

admin/categories/list  
admin/categories/edit/1  
admin/categories/destroy/1  
admin/categories/update/1

Besides, of course, using different controller names  
;). The first URL is publicly accessible, while the  
second contains admin functions. Also, with the  
second, subclassing the Category controller from the  
Admin controller makes it inherit its class functions  
(like before\_filters, layout, etc.), simplifying  
itself and the other children admin controllers quite  
a bit.

Right now, I have a Category controller with many  
before\_filter only/except clauses, and render  
:layout=\>‘public’|‘admin’ in many functions. And I  
have several other contollers - yuck. I thought about  
putting everything in one big monolithic admin  
controller (list\_categories, edit\_category,  
destroy\_category, list\_members, list\_links, etc.).

Thanks for any thoughts!  
csn

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[Yahoo Mail - Organized Email](https://mail.yahoo.com/)**
>
> It's time to get stuff done with Yahoo Mail. Just add your Gmail, Outlook, AOL or Yahoo Mail to get going. We automatically organize all the things life throws at you, like receipts and attachments, so you can find what you need fast. Plus, we've got...

---

<div class="post-metadata">

**Author:** ![csn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@csn](https://www.ruby-forum.com/u/csn)\
**Post date:** [February 13, 2006, 11:09am UTC](https://www.ruby-forum.com/t/categories-and-admin-categories-different-controllers-and/66416/2 "2006-02-13T11:09:10Z")

</div>

I found this:

Controller Inheritance in Rails  
[http://justinfrench.com/index.php?id=122](http://justinfrench.com/index.php?id=122)

Just about what I need, but there are three issues I  
have:

- Would want the base admin controller to be named  
admin\_controller.rb or admin/admin\_controller.rb
- How to define an index method for /admin ?
- I’ve never seen mention of this voodoo in the  
official docs, so maybe it’s unsupported and might  
break in future versions?

csn

— CSN [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> csn  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object

---

<div class="post-metadata">

**Author:** ![csn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/db5fbb/32.png) [@csn](https://www.ruby-forum.com/u/csn)\
**Post date:** [February 13, 2006, 10:32pm UTC](https://www.ruby-forum.com/t/categories-and-admin-categories-different-controllers-and/66416/3 "2006-02-13T22:32:21Z")

</div>

Thought of another way:

# routes.rb: map.admin\_list ‘admin/list/:view’,

:controller=\>‘admin’, :action=\>‘list’ # or  
‘admin/:view/list’

# admin controller:

def list  
case params[:view]  
when ‘categories’  
render :template=\>‘admin/list\_categories’  
when ‘items’  
…  
when ‘links’  
when ‘members’  
when ‘pages’  
end  
end

Pretty simple.

csn

— CSN [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> - How to define an index method for /admin ?  
> use
> 
> > Besides, of course, using different controller  
> > quite
> > 
> > Rails mailing list  
> > [http://mail.yahoo.com](http://mail.yahoo.com)
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

* * *

Do You Yahoo!?  
Tired of spam? Yahoo! Mail has the best spam protection around

> **[\[object](https://mail.yahoo.com/)**
>
> \[object
