Here's the "hello world" program for ramaze:
# you can access it now with http://localhost:7000/
# This should output
# Hello, World!
# in your browser
class MainController < Ramaze::Controller
This is straight from the ramaze.net site but also appears in your examples/basic directory. On my Ubuntu machine it is:
There are other examples in there that may also be of interest.
So, what's going on here? The first couple of lines are bringing in required "libraries" including the ramaze "library" (I'm using the word library here loosely as they aren't compiled libraries as you would normally think of them). The next few lines beginning with a "#" are comments. If you didn't recognize them, you might want to have a basic Ruby book on hand to follow along with. A lot of this won't make sense if you don't know ruby. The next line starts the MainController (we actually could have called it anything) class and tells us it is derived from the Ramaze::Controller class. All of our controllers will be derived from this class. The next three lines define a method
indexfor our class that returns the text string "Hello World!". Finally, we close out the class and start Ramaze.
If you copy this code into a text editor, save it as hello.rb, and then do either:
you should start up the webrick web server. Point your browser to:
and you should see
We're using a few defaults here to get this to display. Notably the fact that if we don't tell Ramaze anything else, it will use the
indexmethod as the default to display. One other item is the ::7000 which is the port to use. 7000 is the default for Ramaze and in a future post, we'll discuss how to change this.. Rails uses 3000 as the default for comparison.
Post any questions or comments on this in the comments section.