SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: Help with routing
-
Dec 1, 2005, 10:17 #1
- Join Date
- May 2005
- Location
- Sweden
- Posts
- 52
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Help with routing
I have a my admin controllers in a folder named admin in my controller folder. It looks something like this:
controllers/admin/authorize_controller.rb
What I want to do is to route the following request "http://www.mypage.com/admin" to that controller, but I don't really know how to do that.
Here is my attempt in the routes.rb file:
PHP Code:map.connect '/admin',
:controller => "authorize",
:action => "authenticate"
-
Dec 1, 2005, 11:19 #2
I was having the same problem the other day as well, but realized that Rails does not need to have a route entry to map to the admin module correctly. (You did generate it as a Admin::authorize right?)
Just remove the route, and try it, maybe using a before_filter to check for the authentication.
-
Dec 2, 2005, 00:03 #3
- Join Date
- Jun 2004
- Location
- California
- Posts
- 440
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'd definitely use a before_filter to check for authentication but to route to something like that you do this:
Code:map.connect '/admin', :controller => 'admin/authorize', :action => 'authenticate'
http://domains.com/admin/admin/controller then to /admin/admin/admin. So remember the leading slash.
-
Dec 2, 2005, 02:49 #4
- Join Date
- May 2005
- Location
- Sweden
- Posts
- 52
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for the reply. Would be interesting hear what you recommend. Is it stupid to have folders in the controller folder? Maybe it's better to make the admin section of a page as component?
Would be interesting to hear how you guys structure a homepage that has both a public and admin version. Do you use shared controllers or do you have on controll for:
news (public controller)
news_admin (admin controller)
It feels important to start structering the page on a good way before going to far in the development.
-
Dec 2, 2005, 08:59 #5
- Join Date
- Jun 2004
- Location
- California
- Posts
- 440
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No it's not stupid to have folders in your controller folder. I use the "admin" folder also, there is nothing wrong with it I don't think. The only thing I don't like about it is that you can't change it...
My structure would be
news
admin/news
But that's just me.
Bookmarks