Learning Ruby On Rails

Learning Ruby On Rails

Inspired by a series from NETTUTS, I have taken up learning a bit about Ruby On Rails. Ruby On Rails, or Rails as it is often referred to, has gained immense popularity with the development and programming world over the past few years since its 2004/2005 release. As a framework on top of Ruby, Rails brings clean code and efficiency to the development of web applications.

Oct 20, 2008 Share No Comments

Ruby On RailsInspired by a series from NETTUTS, I have taken up learning a bit about Ruby On Rails. Ruby On Rails, or Rails as it is often referred to, has gained immense popularity with the development and programming world over the past few years since its 2004/2005 release. As a framework on top of Ruby, Rails brings clean code and efficiency to the development of web applications.

History

Ruby itself was developed by Yukihiro Matsumoto. Released in Japan in 1995 as an open-source, object-oriented language, Ruby was developed with the human, rather than the computer, in mind.

Often people, especially computer engineers, focus on the machines. They think, “By doing this, the machine will run faster. By doing this, the machine will run more effectively. By doing this, the machine will something something something.” They are focusing on machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves.
Yukihiro Matsumoto, via Wikipedia

It was this philosophy that made Ruby so appealing to programmers around the world and helped it spread far beyond the borders of Japan.

Nine or so years later, in 2004, Ruby On Rails was released as an open source framework for Ruby. Rails was developed by David Heinemeier Hansson of 37signals for Basecamp, 37signal’s renowned web based project management software. Ever since, Rails has gained a dedicated and enthusiastic user base and has come to rival such programming giants as PHP.

The Basics

Rails utilizes the Model - View - Controller (MVC) method. This basically means, as far as I understand it, that data and database interaction (the model), user interface elements (the view) and the communication to the model invoked by user actions (the controller), are all kept separate so as to make for a manageable and easily modifiable application. Furthermore, Rails implements the concepts of Convention Over Configuration (CoC) and Don’t Repeat Yourself (DRY). CoC means that the basic structure and framework for an application is already set up for you, speeding up development time. But, when customization and the unconventional is desired, Rails is very extensible and can be configured to ones liking. DRY means that information is kept in one place and can be accessed from that one place, as opposed to the duplication and repetition of commonly used information. In these ways, Rails speeds up development and makes for very clean code.

Installation and Basic Setup

Being a Mac user, I can only attest to the Mac setup (although I do know that Instant Rails is a one-stop Rails installation option for Windows users). Leopard users have it easy; Mac OS 10.5 comes pre-packaged with Ruby and Rails, in addition to various RubyGems (gems are basically plugins for Rails). In order to ensure that the latest versions of Ruby and Rails are installed, these Terminal commands can be used:


sudo gem update –system
sudo gem install rails
sudo gem update rake
sudo gem update sqlite3-ruby

Apple’s Developer Tools also bring efficiency to the Rails workflow on Mac. Xcode comes pre-packaged on Macs, and is also available as a free download on the Apple Developer Connection.

In order to begin a Rails application, type this command in the Terminal:


rails project name

Ruby On Rails Welcome ScreenThis command creates a folder in the specified directory with the basic framework and file structure for an application. Dragging your project folder into the Xcode Organizer allows you to view all your files and run commands from within Xcode. In order to start the server for your application you can either run this command in the Terminal:


script/server

. . . or by creating a new Shell Script action in Xcode with Directory as Top Level Organizer item, Command as script/server and Arguments blank. Run this action by clicking the Run icon in the toolbar. Once the server is initiated, it can be accesed at http://localhost:3000/. You will be greeted with a generic Rails welcome page. From here you can begin adding scaffolding, controllers, views and more to your application.

Resources

Ruby on Rails has a great community following, so their is no shortage of tutorials and resources for Rails. Here are a few:

NETTUTS

NETUTUTS

This is a great series from the always reliable NETTUTS. It takes you through the basic principles of Rails, discusses the project setup and explains the basic syntax of Rails. An article is published every week or so for this series.

Apple Developer Connection

Apple Developer Connection

The ADC provides a handy resource for developing Rails applications on Leopard. Much of this article details the workflow aspect of development, with Xcode and Terminal. In this article, Apple takes us through the creation of a online expense tracking application. All very cool and simple.

Why's Poignant Guide

Why’s Poignant Guide To Ruby

This a truly special guide to Ruby, with illustrations and tangents abound. The author takes us on a, erm, magical journey of elves and such, meanwhile teaching us the fundamentals of Ruby, presenting a very delightful way to learn the language. The illustrations are awesome and the content is awesome. This is not actually about Rails, but still it is important to have a good foundation in Ruby to take advantage of Ruby On Rails.

Along with the official Ror website, a quick Google search will come up with many more good resources.

And, By The Way . . .

I really like the Rails logo. It’s a lot more inspiring than the PHP logo.

Thanks for reading . . . have fun riding the Rails.

Share This Article

Comments (0)

So far, there aren't any comments on this post. Why don't you be the first - just fill out the form below.

Post Your Comment

Comment Guidelines

  • Allowed tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
  • Please be nice and don't spam.
  • If I consider a comment to be impolite, offensive or spammy, I will delete it.
  • If you wish to post code examples, please wrap them in <code> tags.
  • Multi-line code should be wrapped in <pre><code> </code></pre>
  • Use &lt; instead of < and &gt; instead of > in the examples themselves.