Ruby on Rails: Beginning Rails (Page 1 of 4 )
In our last article I left you with a cliffhanger -- you learned to create a third of your first web application with Rails. If you are back here reading this article then my evil plot worked. In this episode we will continue building our first application in Rails and learn to create a basic skeletal framework.
Since it would be a pain in the butt for you to go back to my previous article and learn how to set up the initial part of your first Rails application, I will go ahead and post it here, free of charge. So if you remember that section, feel free to skip over this next part. If not, read on.
Going off the Rails of the Crazy Train
So far in my series of Ruby On Rails tutorials we've only touched upon Ruby (well outside of installation at any rate). In the next few tutorials, we will be using Rails and learning the basics of web development utilizing it.
Whereas Ruby is a programming language, Rails is more of a framework that uses Ruby to do its evil bidding, namely web application building. One of the primary functions of Rails is to build a skeleton application (with default information so there is no need to configure everything).
You should already have a directory created called “ruby.” However if you don't then type the following into your command prompt:
>md ruby
>cd ruby
Next we need to create the framework for our application. To do this all you type in is rails followed by the name of your application. For this example we will type in: rails myfirsttime.
After you type this, your command prompt will go a little nuts, creating four billion files.
If you take a second and go to the directory where your Ruby is installed, you should see a folder named myfirsttime (unless you named your first rails application something else, in which case whatever you named it will be the folder name).
If you double-click on that folder you should see a file folder. Inside of that folder you will notice a read-me file. If you open it, it will explain what each folder is used for. It isn't necessary to learn everything right this moment. Just be aware that the option is available to you.
To start the myfirsttime application, make sure you are in the myfirsttimedirectory:
>cd myfirsttime (note: do not type the “>”)
Next type:
>ruby script/server
The WEBrick will boot and you will see that your application has started on http://0.0.0.:3000. Go ahead and open up a web browser and type http://localhost:3000/ into your URL bar.
To end your WEBrick session press CTRL-C.
Now try going back to http://localhost:3000. It doesn't work right? That's because we ended the WEBrick session.
Next: Controlling the Situation >>
More Ruby-on-Rails Articles
More By James Payne