Your SlideShare is downloading. ×
Ruby on Rails Presentation
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Ruby on Rails Presentation


Published on

An overview of Ruby on Rails for web developers

An overview of Ruby on Rails for web developers

Published in: Technology

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Ruby on Rails “web development that doesn't hurt”
  • 2. “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
  • 3. “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
  • 4. “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
  • 5. “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
  • 6. What is Ruby on Rails? • Ruby is the language • Rails is the framework
  • 7. 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
  • 8. Hello Ruby! puts “Hello Ruby!”
  • 9. More about Ruby • not just for scripting • strives to be programmer friendly • is expressive, human readable • follows the principle of least surprise
  • 10. Ruby has… • dynamic typing (aka duck typing) • blocks (anonymous functions) • closures (like LISP) • “mix-in” modules (multiple inheritance) • operator overloading • open classes
  • 11. Class Example class Person attr_accessor :name end bob = = “Bob the Builder”
  • 12. Blocks & Iterators Example tv_stars = [ bob, pat, maisy, sam ] for character in tv_stars do puts end tv_stars.each { | character | puts }
  • 13. Another Iterator Example cool_stars = { |character| “a” }
  • 14. Ranges Example my_range = 1..10 my_range.each do |x| puts x end
  • 15. Hash Example fav_machines = { “lofty” => 4, “muck” => 3, “scoop” => 8, “dizzy” => 0, “roley” => 5 } fav_machines[“scoop”] »8 fav_machines[“lofty”] += 1 »5 fav_machines[“scrambler”] = 6
  • 16. Open Class Example class Fixnum def + (b) self - b end end 1 + 1 equals 0?!
  • 17. 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
  • 18. Hello Rails! class HelloController < ApplicationController def index @greeting = quot;Hello Rails!” end end <h1><%= @greeting %></h1>
  • 19. 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)
  • 20. 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
  • 21. Active Record • ORM layer supplied with Rails • tables map to classes • rows to objects • columns to object attributes • uses conventions to minimise configuration
  • 22. Active Record Example class Order < ActiveRecord::Base end order = Order.find(1) = 0.5
  • 23. 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
  • 24. 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
  • 25. Migration Example create_table :people do |table| table.column :first_name, :string table.column :last_name, :string table.column :age, :integer end
  • 26. 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
  • 27. Demos
  • 28. Demos
  • 29. Links • Ruby on Rails, • Ruby, • Agile Web Development with Rails, • RailsCasts, • Ruby on Rails Oceania, • Canberra Ruby Crew, • Mike Williams, Ruby@EJA (for some of the presentation material)