SlideShare une entreprise Scribd logo
1  sur  30
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)

Contenu connexe

Tendances

Tendances (20)

Express JS
Express JSExpress JS
Express JS
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
Php basics
Php basicsPhp basics
Php basics
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
HTML & CSS Masterclass
HTML & CSS MasterclassHTML & CSS Masterclass
HTML & CSS Masterclass
 
Express JS
Express JSExpress JS
Express JS
 
PHP
PHPPHP
PHP
 
Django Introduction & Tutorial
Django Introduction & TutorialDjango Introduction & Tutorial
Django Introduction & Tutorial
 
Rest API
Rest APIRest API
Rest API
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
 
An introduction to SQLAlchemy
An introduction to SQLAlchemyAn introduction to SQLAlchemy
An introduction to SQLAlchemy
 
Introduction to laravel framework
Introduction to laravel frameworkIntroduction to laravel framework
Introduction to laravel framework
 
jQuery Ajax
jQuery AjaxjQuery Ajax
jQuery Ajax
 
Introduction To PHP
Introduction To PHPIntroduction To PHP
Introduction To PHP
 

En vedette

Enterprise Architectures with Ruby (and Rails)
Enterprise Architectures with Ruby (and Rails)Enterprise Architectures with Ruby (and Rails)
Enterprise Architectures with Ruby (and Rails)
Konstantin Gredeskoul
 
Distributed Ruby and Rails
Distributed Ruby and RailsDistributed Ruby and Rails
Distributed Ruby and Rails
Wen-Tien Chang
 

En vedette (20)

Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Ruby on Rails for beginners
Ruby on Rails for beginnersRuby on Rails for beginners
Ruby on Rails for beginners
 
Ruby On Rails Presentation
Ruby On Rails PresentationRuby On Rails Presentation
Ruby On Rails Presentation
 
Enterprise Architectures with Ruby (and Rails)
Enterprise Architectures with Ruby (and Rails)Enterprise Architectures with Ruby (and Rails)
Enterprise Architectures with Ruby (and Rails)
 
Ruby On Rails Basics
Ruby On Rails BasicsRuby On Rails Basics
Ruby On Rails Basics
 
ruby on-rails
ruby on-railsruby on-rails
ruby on-rails
 
Intro to Web Development from Bloc.io
Intro to Web Development from Bloc.ioIntro to Web Development from Bloc.io
Intro to Web Development from Bloc.io
 
Collaboration Practices
Collaboration PracticesCollaboration Practices
Collaboration Practices
 
RoR (Ruby on Rails)
RoR (Ruby on Rails)RoR (Ruby on Rails)
RoR (Ruby on Rails)
 
Rails Engine Patterns
Rails Engine PatternsRails Engine Patterns
Rails Engine Patterns
 
Front end development best practices
Front end development best practicesFront end development best practices
Front end development best practices
 
Html css java script basics All about you need
Html css java script basics All about you needHtml css java script basics All about you need
Html css java script basics All about you need
 
Yes, Designer, You CAN Be a Product Leader
Yes, Designer, You CAN Be a Product LeaderYes, Designer, You CAN Be a Product Leader
Yes, Designer, You CAN Be a Product Leader
 
Distributed Ruby and Rails
Distributed Ruby and RailsDistributed Ruby and Rails
Distributed Ruby and Rails
 
An Intro to HTML & CSS
An Intro to HTML & CSSAn Intro to HTML & CSS
An Intro to HTML & CSS
 
Modular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS WorkshopModular HTML, CSS, & JS Workshop
Modular HTML, CSS, & JS Workshop
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 

Similaire à Ruby on Rails Presentation

Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02
sagaroceanic11
 

Similaire à Ruby on Rails Presentation (20)

When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
Road to Rails
Road to RailsRoad to Rails
Road to Rails
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
Ruby on Rails
Ruby on Rails Ruby on Rails
Ruby on Rails
 
Ruby on rails
Ruby on railsRuby on rails
Ruby on rails
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
 
Introduction To Ruby On Rails
Introduction To Ruby On RailsIntroduction To Ruby On Rails
Introduction To Ruby On Rails
 
Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingRuby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programing
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Ruby on Rails
Ruby on RailsRuby on Rails
Ruby on Rails
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Ruby On Rails Introduction
Ruby On Rails IntroductionRuby On Rails Introduction
Ruby On Rails Introduction
 
Happy Coding with Ruby on Rails
Happy Coding with Ruby on RailsHappy Coding with Ruby on Rails
Happy Coding with Ruby on Rails
 
Intro to Rails
Intro to RailsIntro to Rails
Intro to Rails
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Ruby On Rails Intro
Ruby On Rails IntroRuby On Rails Intro
Ruby On Rails Intro
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Ruby on Rails Presentation

  • 1.
  • 2. Ruby on Rails “web development that doesn't hurt”
  • 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
  • 11. Ruby has… • dynamic typing (aka duck typing) • blocks (anonymous functions) • closures (like LISP) • “mix-in” modules (multiple inheritance) • operator overloading • open classes
  • 12. Class Example class Person attr_accessor :name end bob = Person.new bob.name = “Bob the Builder”
  • 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 }
  • 14. Another Iterator Example cool_stars = tv_stars.select { |character| character.name.include? “a” }
  • 15. Ranges Example my_range = 1..10 my_range.each do |x| puts x end
  • 16. 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
  • 17. Open Class Example class Fixnum def + (b) self - b end end 1 + 1 equals 0?!
  • 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
  • 19. Hello Rails! class HelloController < ApplicationController def index @greeting = quot;Hello Rails!” end end <h1><%= @greeting %></h1>
  • 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
  • 26. Migration Example create_table :people do |table| table.column :first_name, :string table.column :last_name, :string table.column :age, :integer 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
  • 28. Demos
  • 29. Demos
  • 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)