I am developing a rails app and have a question.
In my routes.rb:
map.connect 'admin', :controller => "/admin/users", :action => "index"
So when I go to “http://mydomain.com/admin“, it redirects to “http://mydomain.com/admin/users/index“.
However, the address remains as “http://mydomain.com/admin“.
Thus, links in the page are wrong because they are created based on “http://mydomain.com/admin“.
What’s the solution to this problem?
Sam
Your code is not redirecting the browser it’s just setting up /admin and /admin/users to trigger the same action.
You could try:
Then in your controller write:
This will send a redirect to the browser, causing it to display the correct URL.
Hopefully there is a better method that only involves routes.rb. This site might be helpful -> redirect-routing-plugin-for-rails