Getting started with Ruby on rails
By: Emiley J. in Ruby Tutorials on 2008-10-03
First of all you have to check whether Ruby is already installed in your computer. To do that you can follow these steps.
Ruby runs on Windows 2000, Windows XP, or later; Mac OS X; and any version of Unix you're likely to find. You may already have Ruby installed on your machine. To find out, type this at the command
prompt:
prompt> ruby -v
If you see a complaint like "command not found," you'll have to install Ruby.
If Ruby is installed, the response will look something like this:
ruby 1.8.1 (2003-12-25) [powerpc-darwin]
Installing Ruby
in Windows
There is a one-click Ruby installer. You can find it here: http://www.ruby-lang.org/en/downloads/. After you download it, double-click it in Windows Explorer to run it, and then follow the directions. After installing Ruby, close any command-line windows, open a new one, and then follow the directions above to check the installation.
in Mac OS X
Tiger (version 10.4) and later versions of Mac OS X come with recent enough versions of Ruby. If you're using an older release of OS X, see http://www.ruby-lang.org/en/downloads/
Other Unix Variants
You may be able to find precompiled versions of Ruby (RPMs, etc.) in the usual places and retrieve them via the usual tools (apt-get, pkg-get, ports, etc.).
Your Two Basic Tools to use Ruby on rails
There are two basic tools: an editor and an interpreter.
Your Editor
You can use any editor that works with text files to create Ruby scripts. On Windows, I recommend you use SciTE, which is installed with Ruby. It's more than just a text editor: it understands Ruby well enough to color-code parts of a script to make it easier to read, and it lets you run scripts without having to switch to the command line. (In the Start menu's Programs entry, you'll find a Ruby entry, and SciTE is under that.)
On a Mac, I recommend TextMate (http://macromates.com/). It costs money, but you can try a free download. On the Mac and other Unix-like systems, you can use pico. It's free. Start it by typing its name at the command prompt. It shows its available editing commands at the bottom of the screen. In that help,
Control + X is denoted by ˆX.
If you use the Gnome window system on Linux, gedit is worth trying.
irb
The second useful tool is irb. It lets you try your ideas without having to write a whole script. You can type a little snippet of Ruby and quickly check what it does. Now check that irb is ready for use. At the command prompt, type the following. (Remember not to include the prompt.)
prompt> irb
You'll see something like this:
irb(main):001:0>
Most of the pieces of the prompt are unimportant. Now type a Ruby expression, and press Enter (on Windows) or Return (on Unix-like systems):
irb(main):001:0> 1+1
=> 2
irb(main):002:0>
irb displays the result and then prompts you to type something more. 2 is the result of evaluating the expression 1+1.
Exit from irb like this:
irb(main):003:0> exit
prompt>
Add Comment
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Comments