quaggahooliganInternet and Web Development

Feb 5, 2013 (5 years and 5 months ago)


Ruby on Rails

Web development that doesn’t hurt

Ruby on Rails

Framework written in the Ruby
programming language for database
backed web applications

Utilizes MVC design pattern

Created by David Heinemeier Hansson in
mid 2003 and released in 2004

Developed to create the Basecamp
project management web application


Convention over configuration

Almost no configuration files

Helper scripts to get started

Conformity through freebies

Magic wiring relies on common structures
due to conventions of Ruby on Rails

Best practices by invitation

generated unit and integration testing

in Functions

Helper scripts

Create directory hierarchy and skeleton

Create model, view and controller objects

Set up database connectivity


Dynamic method generation

in WEBrick web server


Object Oriented Scripting Language


Open Source

Fully OO that simulates procedurals

Created by Yukihiro Matsumoto (1993)

Publicly released in 1995

New but well documented

Based loosely of Eiffel and Ada but heavily
influenced by other languages like Perl,
Python, Java/JavaScript, etc.

Reflective Language

Ruby incorporates many beneficial
features of other languages

Flexible programming (Perl)

Built in regex (Perl)

Error and Exception Handling (Python, Java)

Mark and Sweep Garbage Collector (Java)

No variable declaration (Perl, PHP, etc)

Embedded doc tools, RDoc (Java)

No Semicolon ‘;’ ! (Python)

Key word parameters *faked* (Python)

And many others

Highlights: Open Classes

Every class, including the core classes can be
modified at any time.

You just need to call

Class class_name

#modification code



#modding floats to output in currency

class Float

def to_m

sprintf("$%.2f", self)



Highlights: Embedded Strings

In Perl and PHP you can embed variables into
strings. In Ruby you can embed whole blocks
of code into string.

Just need to put it between #{ }


#print out the prices in currency format from an

#array without the need to put it back into a


p = [1.25, 2.00, 3.15]

print “Lily: #{p[0].to_m}

Rose: #{p[1].to_m}

Viola: #{p[2].to_m}”

Highlights: RHTML

Ruby can be directly embedded into
HTML much like the way PHP does

Must have eruby (ERb) installed

Trigger ERb with <% %>, <%
and <%= %> tags


<b>Names of all the people</b>

<% for person in @people %>

Name: <%= %><br/>

<% end %>

Future of Ruby

Ruby is easy to learn, simple to understand and
friendly to write in

It has become quite popular and gained a large
following since its release

Ruby’s library is expanding rapidly with many modules
currently being written for it. And with the soon to be
release version 2.0

Not to mention it is completely free

But will all this guarantee that the language won’t
become obsolete once a new language comes out?

It is left to be seen, as the language is too new, and
its support not enough to become a standard

Rails and the MVC Pattern

It is hard to develop with MVC in mind
for most web applications using

Can be done, but requires a lot of work to
create a framework to enforce the MVC

Although other frameworks already exist for
Java (Struts), Perl (Maypole), and for PHP,
they are not integrated deeply in their
respective languages. This is bad because
legacy systems may not be written with
MVC in mind, resulting in spaghetti code.

Rails and the MVC Pattern

RoR integrates and enforces MVC in its

Because of this most all applications
written in RoR follow the MVC design
pattern, and thus allowing for easier
scalability and maintainability.

This significantly reduces the amount of
repeated code. RoR was designed with
ourself philosophy in


The Model in RoR wraps to represent the
RDMBS tables used for a site.

A very minimal amount of configuration needs
to be done. All that needs to be configured is
to tell configure where the database is sitting
and the login information.

Once the database is mapped, each table in
the database is represented by its own class
automatically. This allows ease of access
without any further configuration.

Based on the Active Record pattern.


Uses embedded ruby code in .rhtml files.
Similar to PHP and JSP.



<% Handle Ruby statements here
in embedded. %>




The controller handles the logic, and
responds to user interaction and
manipulates the model.

Out of the box, Rails provides the
controller with prepackaged functions to
easily perform CRUD
operations on the model. No need to
rewrite the same code over and again.

Putting it all together

RoR requires minimal configuration for
implementing MVC. Once a new RoR
project is created, the framework will
automatically create the MVC
components. Each component will map
to each other with little configuration.

AJAX on Rails

Ability to incorporate AJAX (Asychronous
JavaScript and XML) into Rails
driven sites

Contains the Prototype JavaScript library

Works with AJAX functions

Works with (additional functionality
onto Prototype)

Contains helper functions for implementing




AJAX on Rails

No longer a complicated process to
incorporate AJAX onto Rails
driven sites

Newest version of Rails contains RJS

Integrated JavaScript templating language

Create JavaScript using Ruby

Use server
side variables to write JavaScript
and update elements on the fly

Reduce the amount of code needed to
implement AJAX

Applications and Projects




Web pages

DRTV Research

Penny Arcade

Applications: Instiki

based program that focuses on ease of
installation and simplicity in running

2 step method for install

Simplistic user interface

Great for notes, brainstorming, organizing gatherings, file
sharing, etc.

Created by David Heinemeier Hansson, creator of Ruby on

Used for creating and editing web pages

RoR is the structure behind the code of Instiki

Used for database interaction, syntax interpretation, etc.

Applications: TYPO

TYPO is a free, open source (MIT License) blogging
engine written in the Ruby programming languge,
using the Ruby on Rails web application framework

Typo can use any of the various SQL databases
supported by the Ruby on Rails framework

Features include:

Do not need to rebuild the contents of the blog; everything
is created on the fly

Uses caching

based administration and posting interface, plus
support for all three major external client API’s (Blogger,
MetaWeblog and MovableType Extensions)

Web pages: DRTV Research

DRTV Research is a free online application
that combines television lineup listings per
week with consumer demographic data for
North America.

Over 700,000 pages of data are available on
DRTV Research

with new data added daily.

Ruby on rails provides the framework for the
database interaction.

Web pages: Penny Arcade

Penny Arcade

is among the most popular
comics currently online, hosting both a
children's charity (Child’s Play) and a gaming
convention (PAX) each year.

Ruby on Rails framework used for the sites
forums, and database interaction.

Ruby on Rails: Cons

Confined to one language: Ruby

Forced to one directory hierarchy

Not too popular (Though it is becoming
more so recently)

Not yet industry standard

Slight Learning Curve

Relatively new with future stability

Ruby on Rails: Pros

Open Source!

Built for Rapid Application Development

Less development time

Less lines of code

Easy database connectivity

MVC design pattern

in functions

Minimal configuration

Well documented

AJAX made easy


Weblog in 15 minutes

Ruby search engine