Routing the root of the site in rails
This is rails 101 but that’s the class I’m in right now. When you first set up rails, it generates an index.html file that responds to the root index of the application. So going to http://localhost:3001/ takes you to this index.html file. So how do you set up rails so that you can bind this default request to a controller? The index.html actually gives you some hints. Step 3 says:
Set up a default route and remove or rename this file. Routes are setup in config/routes.rb.
It’s a true statement but doesn’t say exactly how to do it. But routes.rb does:
# You can have the root of your site routed by hooking up ”
# — just remember to delete public/index.html.
# map.connect ”, :controller => “welcome”
I made it:
map.connect ”, :controller => ‘home’, :action => ‘index’

October 26th, 2006 00:57
not a bad start for a blog.