Forum: Ruby on Rails categories and admin/categories - different controllers and

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 CSN (Guest)
on 2006-02-13 06:27
(Received via mailing list)
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
http://mail.yahoo.com
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 CSN (Guest)
on 2006-02-13 11:09
(Received via mailing list)
I found this:

Controller Inheritance in Rails
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 <cool_screen_name90001@yahoo.com> wrote:

>
>
> csn
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
81194a50c0f9bd95d7832a77fdf371bd?d=identicon&s=25 CSN (Guest)
on 2006-02-13 22:32
(Received via mailing list)
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 <cool_screen_name90001@yahoo.com> wrote:

> - How to define an index method for /admin ?
> use
> > Besides, of course, using different controller
> > quite
> >
> > Rails mailing list
> http://mail.yahoo.com
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
This topic is locked and can not be replied to.