I have the following at the bot开发者_JAVA百科tom of my routes file:
root :to => 'threads#index', :constraints => lambda {|r| r.env["warden"].authenticate? }
The problem with this is the url is just /, not /threads
How can I get the above to redirect to threads#index or /threads ?
Thanks
If I understand your question correctly, you simply want to change the URL of the root of your site from http://....com/ to http://....com/threads.
In this case, you simply have to add this line:
config.action_controller.relative_url_root = '/threads'
to any of the standard config files, such as config/application.rb, config/development.rb or config/production.rb depending on whether your app is in production mode or development mode.
There is some more information about this on a rails guide: here
EDIT:
It seems that the above solution may not work. Here is one I tried myself. You can simply wrap all your pre-existing routes in a scope, inside your routes.rb file. i.e:
scope "/threads" do
..All your preexisting routes inside this..
end
Note that this will prepend /threads to EVERY path in your app. If you only want this to happen with root, then make sure only the root :to => ... line is wrapped in the scope.
Here's a simple explanation of scopes: here
加载中,请稍侯......
精彩评论