Hello Railers, I''m learning RoR by re-programming my old website from PHP to RoR. I started with the admin part of the site. So, now, when I enter http://my_site/news/list, I see the news listed from the admin part. What is the best practice to obtain a : - http://my_site/admin/news/list (listing the news form the admin) and a : - http://my_site/news/list (listing the news from the public part of the site) Can I create directories in my controllers directory? And for the view? Routes to configure? Can someone give me a clue about where to start to do that? Many thanks! Thomas Balthazar.
Hi ! Thomas Balthazar said the following on 2005-09-05 16:46:> Hello Railers, > > I''m learning RoR by re-programming my old website from PHP to RoR. > I started with the admin part of the site. > So, now, when I enter http://my_site/news/list, I see the news listed > from the admin part. > > What is the best practice to obtain a : > - http://my_site/admin/news/list (listing the news form the admin) > and a : > - http://my_site/news/list (listing the news from the public part of > the site) > > Can I create directories in my controllers directory? > And for the view? > Routes to configure? > > Can someone give me a clue about where to start to do that?If you define your controllers in modules, Rails will know where to search for your controllers, without having to specify any routes. So, if you do: module Admin class NewsController < ApplicationController def list # code end end end Then, this file will be defined in app/controllers/admin/news_controller.rb Rails will look for view files in app/views/admin/news/list.rhtml It will also look for it''s helper in the appropriate spot, etc. In fact, if you use the Generators, all of this will happen automatically: ruby script/generator controller Admin::News list One thing I can''t remember is where I read about this :( It''s probably on the Wiki somewhere, but I haven''t bookmarked or tagged it anywhere. Hope that helps ! François
This is a helpful article: http://justinfrench.com/index.php?id=122> From: Thomas Balthazar <tba-QFKgK+z4sOrR7s880joybQ@public.gmane.org> > Reply-To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Date: Mon, 5 Sep 2005 22:46:47 +0200 > To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Subject: [Rails] url best practice > > Hello Railers, > > I''m learning RoR by re-programming my old website from PHP to RoR. > I started with the admin part of the site. > So, now, when I enter http://my_site/news/list, I see the news listed > from the admin part. > > What is the best practice to obtain a : > - http://my_site/admin/news/list (listing the news form the admin) > and a : > - http://my_site/news/list (listing the news from the public part > of the site) > > Can I create directories in my controllers directory? > And for the view? > Routes to configure? > > Can someone give me a clue about where to start to do that? > > Many thanks! > > Thomas Balthazar. > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails