3. “Rails is the most well thought-out web
development framework I’ve ever used.
And that’s in a decade of doing web
applications for a living. I’ve built my own
frameworks, helped develop the Servlet
API, and have created more than a few
web servers from scratch. Nobody has
done it like this before.”
James Duncan Davidson,
Creator of Tomcat and Ant
4. “Ruby on Rails is a breakthrough in
lowering the barriers of entry to
programming. Powerful web
applications that formerly might
have taken weeks or months to
develop can be produced in a
matter of days.”
Tim O'Reilly,
Founder of O'Reilly Media
5. “It is impossible not to notice Ruby
on Rails. It has had a huge effect
both in and outside the Ruby
community... Rails has become a
standard to which even well-
established tools are comparing
themselves to.”
Martin Fowler, Author of
Refactoring, PoEAA, XP Explained
6. “Ruby on Rails is astounding. Using it is
like watching a kung-fu movie, where a
dozen bad-ass frameworks prepare to
beat up the little newcomer only to be
handed their asses in a variety of
imaginative ways.”
Nathan Torkington,
O'Reilly Program Chair for OSCON
7. What is Ruby on Rails?
• Ruby is the language
• Rails is the framework
8. What is Ruby?
• created by Yukihiro Matsumoto (quot;Matzquot;)
in 1993
• open source
• interpreted
• object-oriented (everything is an object)
• combines syntax inspired by Perl with
Smalltalk-like features
10. More about Ruby
• not just for scripting
• strives to be programmer friendly
• is expressive, human readable
• follows the principle of least surprise
13. Blocks & Iterators Example
tv_stars = [ bob, pat, maisy, sam ]
for character in tv_stars do
puts character.name
end
tv_stars.each { | character |
puts character.name
}
18. What is Rails?
• created by David Heinemeier Hansson
(quot;DHHquot;) of 37 Signals in 2004
• open source
• a web framework that is optimized for
programmer happiness
• designed for developing database-backed
web applications
• designed for agile development
20. More about Rails
• it is “opinionated” software
• uses convention over configuration
• uses the Model-View-Controller pattern
• focuses on CRUD
• uses object relational mapping
• follows principle of DRY (don’t repeat
yourself)
21. Rails Supports…
• BDD, TDD and automated testing
• AJAX and web services: SOAP, XML-RPC,
REST
• meta-programming and domain specific
languages
• variety of databases: MySQL, PostgreSQL,
SQLite, Oracle, SQL Server, DB2 etc
• variety of web servers: Apache, lighttpd,
nginx, Mongrel etc
• most platforms: Windows, Mac, Linux
22. Active Record
• ORM layer supplied with Rails
• tables map to classes
• rows to objects
• columns to object attributes
• uses conventions to minimise
configuration
23. Active Record Example
class Order < ActiveRecord::Base
end
order = Order.find(1)
order.discount = 0.5
order.save
24. Relationship Example
class Person < ActiveRecord::Base
end
class Event < ActiveRecord::Base
has_and_belongs_to_many :participants,
:class_name => quot;Personquot;
end
party_people = Event.find(1).participants
25. Better Example
class Project < ActiveRecord::Base
belongs_to :portfolio
has_one :project_manager
has_many :milestones
has_many :deliverables, :through => :milestones
validates_presence_of :name, :description
validates_acceptance_of :non_disclosure_agreement
validates_uniqueness_of :short_name
end
27. BDD Example (RSpec)
describe User do
it quot;should be invalid without a usernamequot; do
@user.attributes = valid_user_attributes.except(:username)
@user.should_not_be_valid
@user.errors.on(:username).should_equal quot;is requiredquot;
@user.username = 'someusername'
@user.should_be_valid
end
it “should be invalid without an emailquot;
it quot;should be invalid without a password”
end
30. Links
• Ruby on Rails, rubyonrails.com
• Ruby, ruby-lang.org
• Agile Web Development with Rails, pragprog.com
• RailsCasts, railscasts.com
• Ruby on Rails Oceania, rubyonrails.com.au
• Canberra Ruby Crew, canberraruby.com
• Mike Williams, dogbiscuit.org/mdub/presentations/
Ruby@EJA
(for some of the presentation material)