ncooper09 ncooper09 - 5 months ago 12x
Ruby Question

Rails Tutorial- cannot get rails to recognize route

I am new to programming in general, someone referred me to

Specs: I am working on a cloud9 IDE, as suggested in the tutorial.

Information: I am on 1.3 of the rails tutorial, which is setting the root route.
The problem was initially my route did not effect the server launch (root page was still ruby default, not to 'application#hello'). Here are the files that the tutorial said to edit.


Rails.application.routes.draw do
root to: 'application#hello'


class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def hello
render text: "Hello, world!"

There are a lot of comments that were defaulted into the files that I left out.

I have followed the instructions precisely. After I first had trouble, I thought I may have made an installation error, so I deleted my IDE and restarted, paying extreme attention to detail, especially versions.

I have tried $ rake routes, and my understanding it gives the message:

You don't have any routes defined!

That leads me to believe that the problem is the routes.rb file. I have tried changing the syntax to:

root to: 'application#hello'

I don't know a whole lot, such as how it would work using application, so I also tried:

root 'ApplicationController#hello'


root to: 'ApplicationController#hello'

These all result in the no routes defined message. I have no idea what is going on.

Thanks for any input or help!


You could try root 'application#hello' in your routes. Also, when starting out simple things like forgetting to save the file before trying things out on the browser can slip by; restarting the server takes care of a surprising number of foibles.

The rails documentation can also provide you a bit more information beyond the tutorial.