Changing Index Page - Ruby on Rails

bgadoci picture bgadoci · Nov 24, 2009 · Viewed 12.1k times · Source

I am new to rails so go easy. I have developed my blog and deployed it successfully. The entire app is based out of the post_controller. I am wondering how I can reroute the users path to default to the post_controller vs. the app controller.

To illustrate, if you go to http://mylifebattlecry.heroku.com you will see the default rails page. If you go to http://mylifebattlecry.heroku.com/posts you will see the the app. Once I complete this I will change my domain of http://www.mylifebattlecry.com to map to Heroku but need to know how to get the /posts to be where the visitor is sent.

Answer

MattMcKnight picture MattMcKnight · Nov 24, 2009

You need to do two things

  1. Delete the file /public/index.html
  2. Update the file /config/routes.rb

map.root :controller => "posts" #RAILS 2

or

root :to => 'posts#index' #RAILS 3

This will then call the index action in your posts controller. You will need to restart the application to see changes to routes.rb