I’m trying to create a modules based system where my controllers are
all under modules. So the structure looks something like:
app/
controllers/
message/
news_controller.rb
email_controller.rb
library
books_controller.rb
pictures_controller.rb
home_page_controller.rb
Each of those controller has it’s own view, and there’s a central
application.rhtml for the layout. The layout has in it links to each
of the controllers using the form:
url_for(:controller => ‘message/news’, :action => ‘show’)
The routing is:
map.connect ‘’, :controller => ‘home_page’, :action => ‘show’
map.connect ‘/home_page’, :controller => ‘home_page’, :action =>
‘show’
map.connect ‘/news’ , :controller => ‘message/news’ , :action =>
‘show’
map.connect ‘/books’ , :controller => ‘library/books’ , :action =>
‘show’
Install the default route as the lowest priority.
map.connect ‘:controller/:action/:id’
When I access the initial page - http://localhost:3000/ everything is
fine, but once I access one of the shortcuts, i.e.
https://localhost:3000/books, the url_for(:controller =>
‘message/news’, :action => ‘show’) will return a wrong url. What I get
is:
http://localhost:3000/books/message/news/show. As you can see the
/books part remains part of the URL, though I don’t see why the
url_for() will not ignore this part. Actually, url_for returns
/books/message/news/show. The protocol and host are added by the
client. But still, the /books part should not be there.
Any pointers as to how I should handle that?
Bye,
Guy
Family management on rails: http://www.famundo.com - coming soon!