Hi- I''m new to RoR (as probably evidenced by this post). What I want to do is group some controllers beneath a subdirectory. For instance, I want to have a http://www.mysite.com/admin section of the site that has areas for managing users, products, etc. using URLs like http://www.mysite.com/admin/user/new and so on. My question is twofold. First, what is the best way to do this? Second, is this the RoR way to do things or am I thinking in the paradigm of more traditionla web frameworks. Regards- Eric P.S. - Sorry if this question has been answered. Searhcing for "directory" and "subdirectory" gives noisy results. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 28, 2007 4:19 PM, emarthinsen <emarthinsen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m new to RoR (as probably evidenced by this post). What I want to do > is group some controllers beneath a subdirectory. For instance, I want > to have a http://www.mysite.com/admin section of the site that has > areas for managing users, products, etc. using URLs like > http://www.mysite.com/admin/user/new and so on. My question is > twofold. First, what is the best way to do this? Second, is this the > RoR way to do things or am I thinking in the paradigm of more > traditionla web frameworks.You can create routes to make the urls appear however you want, no sub-directories required. Have a look at http://manuals.rubyonrails.com/read/chapter/65 -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You can do this nicely & transparently in Rails: # file: app/controllers/admin/users_controller.rb class Admin::UsersController < ApplicationController end Then: url_for( :controller => ''admin/users'', :action => ''new'' ) => .../admin/users/new Ie: 1. You put your controller in a subdirectory ''admin'' in ''app/ controllers'' directory 2. You namespace the controller (Admin::UsersController) 3. You put your views in corresponding directory (app/views/admin/ users) -- but you don''t have to 3. Don''t forget to use correct syntaxt in url_for, link_to, render (eg. render :template => ''admin/new'') Cheers, Karel P.S. You can even subclass your Admin::UsersController from your "default" or "presentation layer" UsersController and use inheritance this way. On Nov 28, 11:19 pm, emarthinsen <emarthin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi- > > I''m new to RoR (as probably evidenced by this post). What I want to do > is group some controllers beneath a subdirectory. For instance, I want > to have ahttp://www.mysite.com/adminsection of the site that has > areas for managing users, products, etc. using URLs likehttp://www.mysite.com/admin/user/newand so on. My question is > twofold. First, what is the best way to do this? Second, is this the > RoR way to do things or am I thinking in the paradigm of more > traditionla web frameworks. > > Regards- > Eric > > P.S. - Sorry if this question has been answered. Searhcing for > "directory" and "subdirectory" gives noisy results.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---