What I want to do is wrap all the scaffolded administrated pages for my
webapp into an admin folder in the controllers and views folders.
So...
/app
/controllers
/admin
issue_controller.rb
article_controller.rb
topic_controller.rb
... etc. ...
/views
/admin
/issue
_form.rhtml
edit.rhtml
list.rhtml
new.rhtml
show.rhtml
/article
/topic
... etc. ...
My question is how do I set up a good, clean route that can accomodate
this?
I''ve tried a few things that don''t seem to work. I thought
this would
be golden, but apparently not:
map.connect ''admin/:controller/:action/:id''
Any help would be much appreciated!
--
Posted via http://www.ruby-forum.com/.
This is what I''m going with for the time being and works perfectly: map.admin_issue ''admin/issue/:action/:id'', :controller => ''admin/issue'' map.admin_article ''admin/article/:action/:id'', :controller => ''admin/article'' map.admin_topic ''admin/topic/:action/:id'', :controller => ''admin/topic'' etc. Is there a more efficient way? Not that five or ten lines is much worse than one, but hey... that''s part of what makes Ruby and Rails so great, right?! :) -- Posted via http://www.ruby-forum.com/.
If you generate your controller as script/generate controller admin::some_controller It will put the some_controller into an admin directory and the class definition will be class Admin::SomeController < ApplicationController I have not needed to add anything to the standard route file for this to work as http://localhost:3000/admin/some_controller/method I don''t know if you can just change your admin controller class definition to include the Admin:: part but I don''t see why it wouldn''t work. On 6/15/06, Dan Croak <dancroak@yahoo.com> wrote:> > This is what I''m going with for the time being and works perfectly: > > map.admin_issue ''admin/issue/:action/:id'', :controller => ''admin/issue'' > map.admin_article ''admin/article/:action/:id'', :controller => > ''admin/article'' > map.admin_topic ''admin/topic/:action/:id'', :controller => ''admin/topic'' > > etc. > > Is there a more efficient way? Not that five or ten lines is much worse > than one, but hey... that''s part of what makes Ruby and Rails so great, > right?! > > :) > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060615/3d6cf087/attachment.html
Daniel ----- wrote:> If you generate your controller as > > script/generate controller admin::some_controller > > It will put the some_controller into an admin directory and the class > definition will be > > class Admin::SomeController < ApplicationController > > I have not needed to add anything to the standard route file for this to > work as > > http://localhost:3000/admin/some_controller/method > > I don''t know if you can just change your admin controller class > definition > to include the Admin:: part but I don''t see why it wouldn''t work.Thanks, Daniel! I did something similar... ruby script/generate scaffold issue admin/issue The controller ends up looking just like you said, but perhaps when I generate the scaffold, I should do admin::issue instead of admin/issue. -- Posted via http://www.ruby-forum.com/.