• Like
  • Save
Ruby on Rails Presentation
Upcoming SlideShare
Loading in...5
×
 

Ruby on Rails Presentation

on

  • 1,247 views

An overview of Ruby on Rails for web developers

An overview of Ruby on Rails for web developers

Statistics

Views

Total Views
1,247
Views on SlideShare
1,246
Embed Views
1

Actions

Likes
0
Downloads
0
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Ruby on Rails Presentation Ruby on Rails Presentation Presentation Transcript

    • Ruby on Rails “web development that doesn't hurt”
    • “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
    • “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
    • “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
    • “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
    • What is Ruby on Rails? • Ruby is the language • Rails is the framework
    • 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
    • Hello Ruby! puts “Hello Ruby!”
    • More about Ruby • not just for scripting • strives to be programmer friendly • is expressive, human readable • follows the principle of least surprise
    • Ruby has… • dynamic typing (aka duck typing) • blocks (anonymous functions) • closures (like LISP) • “mix-in” modules (multiple inheritance) • operator overloading • open classes
    • Class Example class Person attr_accessor :name end bob = Person.new bob.name = “Bob the Builder”
    • 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 }
    • Another Iterator Example cool_stars = tv_stars.select { |character| character.name.include? “a” }
    • Ranges Example my_range = 1..10 my_range.each do |x| puts x end
    • 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
    • Open Class Example class Fixnum def + (b) self - b end end 1 + 1 equals 0?!
    • 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
    • Hello Rails! class HelloController < ApplicationController def index @greeting = quot;Hello Rails!” end end <h1><%= @greeting %></h1>
    • 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)
    • 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
    • Active Record • ORM layer supplied with Rails • tables map to classes • rows to objects • columns to object attributes • uses conventions to minimise configuration
    • Active Record Example class Order < ActiveRecord::Base end order = Order.find(1) order.discount = 0.5 order.save
    • 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
    • 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
    • Migration Example create_table :people do |table| table.column :first_name, :string table.column :last_name, :string table.column :age, :integer end
    • 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
    • Demos
    • Demos
    • 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)