Command not found when I write "hello world"


#1

I just started Michael Hartl’s world famous tutorial and I was going along like a coding boss and then I hit a humiliating wall. I can’t get Ruby to let me say “hello world” I get a command not found when I type ‘$ hello world’

My application controller does not have any syntax errors. See below:

class ApplicationController < ActionController::Base

Prevent CSRF attacks by raising an exception.

For APIs, you may want to use :null_session instead.

protect_from_forgery with: :exception

def hello
render text: "hello, world!"
end
end


#2

What is the name of the file? You are likely supposed to run that or call it with ruby, not literally type ‘$ hello world’


#3

Thank you for your reply Justin8.

The way I understand the tutorial, I am supposed to type $ hello world after I see this line:

~/workspace/hello_app

Then that tells the server to display hello world. I have not been able to get that to happen, so I have to figure out how to start from the beginning to the tutorial with all of the default folders and gem files.


#4

HI @cajinc126,

Not having taken the tutorial myself, I’m not sure, but adding the ActionController::Base and render text: would indicate that you’re writing a rails app, and not a command line app.

You can start the rails server by running rails s -b $IP -p $PORT on the terminal.

Regards,
​Mutahhir