I’m trying to learn web-dev and decided to learn ruby on rails. I’m doing the first tutorial from “Agile Web Development with Rails”. I’ve seen there are quite a few search results on google, but all the recommendation is “to restart the server”, which does not help my case.
So, I started webrick and generate controller Say with these code:
def hello
end
and then I added hello.rhtml, which has some basic html with message “Hello from rails”.
When i type in browser: http://localhost:3000/say/hello
I get : No route matches [GET] “/say/hello”
I tried to restart webrick, doesn’t work. The bug-name suggest it has to do with routes, i’ve got two versions of the book, none of them have the steps to alter the routes.rb and within routes.rb i have commented-out stuff and class definition.
Does anyone know what should i do?
I’m guessing is a problem in your routes file. You need to define what you want rails to do (which controller+action you want to be perform) when that URL is received. So, do the following:
This will tell rails that when a URL with say/hello is received, the hello action of the controller say has to be performed.