Is it possible to have controllers named the following? /admin /admin/user If not, is there some way to get it to work with routes? I want to have some actions at the url /admin/<action> and some at /admin/user/<action> (obviously in admin/user controller). Thanks!!!
On Mar 14, 2006, at 9:56 AM, Chris Bruce wrote:> Is it possible to have controllers named the following? > /admin > /admin/user > > If not, is there some way to get it to work with routes? > > I want to have some actions at the url /admin/<action> and some at > /admin/user/<action> (obviously in admin/user controller).See the following for a good write-up on this... <http://justinfrench.com/index.php?id=122> -S
Thanks for the info, but that isn''t quite what I am looking for. I am concerned about the fact that in my example below, the admin controller will be invoked with the url /admin/user/myaction when I really want the admin/user controller invoked. Chris -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Sean Stephens Sent: Tuesday, March 14, 2006 9:05 AM To: rails@lists.rubyonrails.org Subject: Re: [Rails] Controller Naming Question On Mar 14, 2006, at 9:56 AM, Chris Bruce wrote:> Is it possible to have controllers named the following? > /admin > /admin/user > > If not, is there some way to get it to work with routes? > > I want to have some actions at the url /admin/<action> and some at > /admin/user/<action> (obviously in admin/user controller).See the following for a good write-up on this... <http://justinfrench.com/index.php?id=122> -S _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hey Chris, You can define an index method which will be used as the default? Or you can make your index action reference another action (which is probably cleaner). Just wondering, but why are you looking to do this exactly? What''s wrong with the URL as it is? Brian Corrigan -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Chris Bruce Sent: Tuesday, March 14, 2006 12:11 PM To: rails@lists.rubyonrails.org Subject: RE: [Rails] Controller Naming Question Thanks for the info, but that isn''t quite what I am looking for. I am concerned about the fact that in my example below, the admin controller will be invoked with the url /admin/user/myaction when I really want the admin/user controller invoked. Chris -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Sean Stephens Sent: Tuesday, March 14, 2006 9:05 AM To: rails@lists.rubyonrails.org Subject: Re: [Rails] Controller Naming Question On Mar 14, 2006, at 9:56 AM, Chris Bruce wrote:> Is it possible to have controllers named the following? > /admin > /admin/user > > If not, is there some way to get it to work with routes? > > I want to have some actions at the url /admin/<action> and some at > /admin/user/<action> (obviously in admin/user controller).See the following for a good write-up on this... <http://justinfrench.com/index.php?id=122> -S _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
I am trying to port an existing site with an existing url structure that we would like to keep. It would be a lot cleaner too. Chris Brian Corrigan wrote:> Hey Chris, > > You can define an index method which will be used as the default? Or > you can make your index action reference another action (which is > probably cleaner). > > Just wondering, but why are you looking to do this exactly? What''s > wrong with the URL as it is? > > Brian Corrigan-- Posted via http://www.ruby-forum.com/.
On 3/14/06, Chris Bruce <cbruce@sleeter.com> wrote:> Is it possible to have controllers named the following? > /admin > /admin/userSure. The first controller would be named Admin and the second one Admin::User, actually a User controller class inside a module named Admin. However, just naming them correctly won''t do, the default routing mechanism will interpret /admin/user as the action ''user'' from the controller ''admin''. You can achieve what you want by tweaking your routes, make sure to add something like this on the top of the routes.rb file (it needs to be on top, so it matches at a higher priority than the default route): --------- map.connect ''admin/user/:action'', :controller => ''admin/user'' --------- Good luck, Thiago Arrais