Introduction to Ruby on Rails

Introduction to Ruby on Rails
Difficulty: Moderate
Description: An Introduction to Ruby and Rails (to be continued)
Author: Founder; Date Added: 2007-04-26; Views: 15594

Part 1: Installation

As Ruby and Rails are constantly evolving it can sometimes be a chore to install the latest version. There are quite a few ways you can go about installing Ruby the first and easiest would be to us the One-Click Ruby installer which can be found here: http://rubyforge.org/projects/rubyinstaller/

The One-Click Ruby Installer is:

A self-contained installer that includes the Ruby language, dozens of popular extensions, a syntax-highlighting editor and the book "Programming Ruby: The Pragmatic Programmer's Guide". Platforms: Windows NT/2000/XP, (OS X in development).


After the installation, open your command prompt and type
gem install rails --include-dependencies
Awesome! Now we're on Rails!

Note: This is my preferred method of installing Ruby and Rails, but it can also be installed via InstantRails which is found here: http://rubyforge.org/frs/?group_id=904

For an IDE if you're into that sort of stuff (it can make things easier, or complicate them, I'm generally in favor of them though) I HIGHLY recommend RadRails which can be obtained at: http://www.radrails.org/

Note: Aptana can also be obtained from that website, Aptana is my favorite CSS IDE, but you probably don't care about that. We're here for ruby!

Part 2: MVC

MVC stand for Model, View, Controller which is the basic architecture of Ruby on Rails. The Model controls the state of the project, it's a very flexible thing and allows you to enforce your rules with an iron fist! For example, unless a user of Gamexe is not a moderator they aren't allowed to edit others posts. Without a model enforcing that rule, well... the results could be potentially disastrous.

The View builds the user database from the information contained in the model. For example, the model could contain all of my posts and the view could format these posts so everyone can look at them. The view will

never

handle data, just display it.

The Controller handles the data from the model and view. When a user interacts with a view, the data is passed through the controller and queries the data from the model and manipulates if need be.


Thus, we have a circle.... errr more like a rhombus in my highly professional image.

Part 3: Syntax!

You didn't really think we'd jump into the syntax that early did you? Now, it's time to look at a few simple Ruby commands, I could tell you... but I have a better idea. How about you go try Ruby in your browser. You're probably wondering what the **** I'm talking about, well just take a visit here: http://tryruby.hobix.com/ and you'll understand. It will do you a lot more good than anything I could ever tell you, and you'll understand how Ruby works so I can teach you a bit about rails. Would I ever mislead you? :wink:

To be continued....