bgadoci
bgadoci

Reputation: 6493

Changing Index Page - Ruby on Rails

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.

Upvotes: 11

Views: 13122

Answers (2)

MattMcKnight
MattMcKnight

Reputation: 8290

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

Upvotes: 15

khelll
khelll

Reputation: 23990

Add the following line to your confing/routes.rb:

map.root :controller => "posts"

You need to restart your server after that.

Upvotes: 0

Related Questions