Edit the root route


Now that we have a working prototype, let's make it accessible to new users.

If you go now to localhost:3000, or if you had your app not on your local computer, but on your internet domain, you still see the default Rails welcome message.

We would like instead to see localhost:3000/posts page. Thus, if the user is signed in, they will see the posts page. Otherwise, they will be prompted to sign in, according to the before_filter we applied in the posts controller.

Let's tell our app what route to take by default, or as it is called in rails, where is the root of our app. In /config/routes.rb before the end keyword type:

root to: "posts#index"

This will send you by default to localhost:3000/posts, which is the address linked to the action posts#index.

In general, to verify which action leads to which browser path, type

$ rails routes

in the terminal. Now you can see that / is the address linked to posts#index.

results matching ""

    No results matching ""