CSN
2006-Feb-13 05:26 UTC
[Rails] categories and admin/categories - different controllers and templates?
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
CSN
2006-Feb-13 10:08 UTC
[Rails] categories and admin/categories - different controllers and templates?
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:> 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 > _______________________________________________ > 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
CSN
2006-Feb-13 21:32 UTC
[Rails] categories and admin/categories - different controllers and templates?
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:> 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: > > > 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 > > _______________________________________________ > > 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 > _______________________________________________ > 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