SlideShare uma empresa Scribd logo
1 de 68
Baixar para ler offline
presents


      Ruby on Rails 3.1
Let’s bring the fun back to web programming!



              Bozhidar Batsov
               Technical Lead
The problem
Many programmers are
not particularly happy
It's the question that drives
us, Neo. It's the question that
 brought you here. You know
  the question, just as I did.
     What is the question?
How can I be
   be one happy
(web) programmer?
VS.   VS.
VS.   VS.
This PHP code is so
clean and elegantly
solves the problem at
hand.
           Nobody, Never
PHP

                0   10   20   30   40   50    60   70   80   90   100
      OOP

         FP

Performance

 Productivity

          Fun
The Zen of Python
There should be one –
and preferably only one
– obvious way to do it.
Python

               0   10   20   30   40   50   60   70   80   90   100
      OOP

        FP

Performance

Productivity

         Fun
The Web framework for
  perfectionists with
      deadlines.
2007
A Programmer’s Best Friend
The goal of Ruby is to make
programmers happy. I started out
to make a programming language that
would make me happy, and as a side
effect it’s made many, many programmers
happy. Especially   Web
developers.

           Yukihiro “Matz” Matsumoto,
                 creator of Ruby
Ruby

                0   10   20   30   40   50   60   70   80   90   100

      OOP


         FP

Performance

 Productivity

          Fun
PHP             Python           Ruby

                0    10   20   30    40   50   60   70   80   90   100

      OOP


         FP

Performance

 Productivity

          Fun
Startup Technologies 2011




                                                              30

                                                              27

                                                          24
                                                          21
                                                         18
                                                         15
                                                         12
                                                     9
                                                     6
JQuery                                               3
                Django                               0

                                     Ruby on Rails
http://www.ruby-toolbox.com
“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
“Rails is the killer app
       for Ruby.”

 Yukihiro Matsumoto,
   Creator of Ruby
Convention
    over
Configuration
DRY
  (Don’t
 repeat
yourself)
Many view (template)
                      options

              HTML + Erb                                      Haml
<div id="profile">                                      #profile
  <div class="left column">                               .left.column
    <div id="date"><%= print_date %></div>                  #date= print_date
    <div id="address"><%= current_user.address %></div>     #address= current_user.address
  </div>                                                  .right.column
  <div class="right column">                                #email= current_user.email
    <div id="email"><%= current_user.email %></div>         #bio= current_user.bio
    <div id="bio"><%= current_user.bio %></div>
  </div>
</div>
doctype html
html
  head
     title Slim Core Example
     meta name="keywords" content="template language"

  body
    h1 Markup examples

    div id="content" class="example1"
      p Nest by indentation

      == yield

      - unless items.empty?
        table
           - for item in items do
             tr
                td = item.name
                td = item.price
      - else
        p
          | No items found. Please add some
inventory.
             Thank you!

    div id="footer"
      | Copyright © 2010 Andrew Stone

    = render 'tracking_code'

    javascript:
      $(content).do_something();
Testing in Rails is not
       optional!
All the code
is guilty until
     proven
   innocent!
DSL FTW
ActiveRecord
class Page < ActiveRecord::Base
  has_many :page_images, :dependent => :destroy

  validates :title, :presence => true, :uniqueness => true
  validates :content, :presence => true
  validates :permalink, :presence => true, :uniqueness => true

  accepts_nested_attributes_for :page_images, :allow_destroy => true

  def to_param
    permalink
  end
end
XML Free
 development:
  adapter: postgresql
  database: mycoolproject
  host: localhost
  username: mycoolproject
  password: mycoolproject
  encoding: utf8

 test:
   adapter: sqlite3
   database: db/test.sqlite3
   pool: 5
   timeout: 5000
UNIX Certified
rails g (generate)

rails c (console)

rails db (dbconsole)

rake

bundle
Agile
Innovation
Lots of
friends
Fo
   r   k
           me
                on
                     Git
                           Hu
                                b!
Fantastic documentation

RailsGuides (http://guide.rubyonrails.org)

RailsCasts (http://railscasts.org)

PragProg

Ruby on Rails 3 Tutorial (http://ruby.railstutorial.org/)
The Dark Art of
  Deployment
In the clouds...

              ?
$   heroku create --stack cedar
$   git push heroku master
$   heroku open
$   heroku scale web=100 worker=50
Happy programmers
Rails 3.1
CoffeeScript
# Assignment:
number   = 42
opposite = true

# Conditions:
number = -42 if opposite

# Functions:
square = (x) -> x * x

# Arrays:
list = [1, 2, 3, 4, 5]

# Objects:
math =
  root:    Math.sqrt
  square: square
  cube:    (x) -> x * square x

# Splats:
race = (winner, runners...) ->
  print winner, runners

# Existence:
alert "I knew it!" if elvis?

# Array comprehensions:
cubes = (math.cube num for num in list)
JavaScript
var cubes, list, math, num, number, opposite, race, square;
var __slice = Array.prototype.slice;
number = 42;
opposite = true;
if (opposite) number = -42;
square = function(x) {
  return x * x;
};
list = [1, 2, 3, 4, 5];
math = {
  root: Math.sqrt,
  square: square,
  cube: function(x) {
    return x * square(x);
  }
};
race = function() {
  var runners, winner;
  winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
  return print(winner, runners);
};
if (typeof elvis !== "undefined" && elvis !== null) alert("I knew it!");
cubes = (function() {
  var _i, _len, _results;
  _results = [];
  for (_i = 0, _len = list.length; _i < _len; _i++) {
    num = list[_i];
    _results.push(math.cube(num));
  }
  return _results;
})();
Asset Pipeline
SASS
$blue: #3bbfce;           .content-navigation {
$margin: 16px;              border-color: #3bbfce;
                            color: #2b9eab;
.content-navigation {     }
  border-color: $blue;
  color:                  .border {
    darken($blue, 9%);      padding: 8px;
}                           margin: 8px;
                            border-color: #3bbfce;
.border {                 }
  padding: $margin / 2;
  margin: $margin / 2;
  border-color: $blue;
}
table.hl {               table.hl {
  margin: 2em 0;           margin: 2em 0;
  td.ln {                }
    text-align: right;   table.hl td.ln {
  }                        text-align: right;
}                        }

li {                     li {
  font: {                  font-family: serif;
     family: serif;        font-weight: bold;
     weight: bold;         font-size: 1.2em;
     size: 1.2em;        }
  }
}
@mixin table-base {       #data {
  th {                      float: left;
    text-align: center;     margin-left: 10px;
    font-weight: bold;    }
  }                       #data th {
  td, th {padding: 2px}     text-align: center;
}                           font-weight: bold;
                          }
@mixin left($dist) {      #data td, #data th {
  float: left;              padding: 2px;
  margin-left: $dist;     }
}

#data {
  @include left(10px);
  @include table-base;
}
.error {               .error, .badError {
  border: 1px #f00;      border: 1px #f00;
  background: #fdd;      background: #fdd;
}                      }
.error.intrusion {
                       .error.intrusion,
  font-size: 1.3em;
                       .badError.intrusion
  font-weight: bold;
                       {
}
                         font-size: 1.3em;
.badError {              font-weight: bold;
  @extend .error;      }
  border-width: 3px;
                       .badError {
}
                         border-width: 3px;
                       }
Always in motion the future is...
Rails 4.0


targeting Ruby 1.9.2

expected in an year

it will be the end of the world as we know
it :-)
About Bozhidar


bozhidar@empowerunited.com

http://batsov.com

@bbatsov

http://github.com/bbatsov
Q&A
(any questions?!)
Thanks!

Don’t leave just yet ;-)
you@empowerunited.com
facebook.com/empoweronrails

Mais conteúdo relacionado

Mais procurados

Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Kaelig Deloumeau-Prigent
 
Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)
Jacob Kaplan-Moss
 
Your code sucks, let's fix it! - php|tek13
Your code sucks, let's fix it! - php|tek13Your code sucks, let's fix it! - php|tek13
Your code sucks, let's fix it! - php|tek13
Rafael Dohms
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
Dinu Suman
 

Mais procurados (20)

Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
 
非同期処理の通知処理 with Tatsumaki
非同期処理の通知処理 with Tatsumaki非同期処理の通知処理 with Tatsumaki
非同期処理の通知処理 with Tatsumaki
 
Everest
EverestEverest
Everest
 
Sencha Touch
Sencha TouchSencha Touch
Sencha Touch
 
HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?HTML5: friend or foe (to Flash)?
HTML5: friend or foe (to Flash)?
 
Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019Let's write secure drupal code! - Drupal Camp Pannonia 2019
Let's write secure drupal code! - Drupal Camp Pannonia 2019
 
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJRealize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
Realize mais com HTML 5 e CSS 3 - 16 EDTED - RJ
 
Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)Introduction To Django (Strange Loop 2011)
Introduction To Django (Strange Loop 2011)
 
Ruby gems
Ruby gemsRuby gems
Ruby gems
 
Html5
Html5Html5
Html5
 
Worth the hype - styled components
Worth the hype - styled componentsWorth the hype - styled components
Worth the hype - styled components
 
Top 10 php classic traps php serbia
Top 10 php classic traps php serbiaTop 10 php classic traps php serbia
Top 10 php classic traps php serbia
 
Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019Let's write secure Drupal code! DUG Belgium - 08/08/2019
Let's write secure Drupal code! DUG Belgium - 08/08/2019
 
Your code sucks, let's fix it! - php|tek13
Your code sucks, let's fix it! - php|tek13Your code sucks, let's fix it! - php|tek13
Your code sucks, let's fix it! - php|tek13
 
Reitit - Clojure/North 2019
Reitit - Clojure/North 2019Reitit - Clojure/North 2019
Reitit - Clojure/North 2019
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
 
The Ring programming language version 1.7 book - Part 49 of 196
The Ring programming language version 1.7 book - Part 49 of 196The Ring programming language version 1.7 book - Part 49 of 196
The Ring programming language version 1.7 book - Part 49 of 196
 
PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)
 
Working With Canvas
Working With CanvasWorking With Canvas
Working With Canvas
 

Semelhante a Ruby on Rails 3.1: Let's bring the fun back into web programing

Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
Bryce Kerley
 
Vaadin Introduction at OOP 2014
Vaadin Introduction at OOP 2014Vaadin Introduction at OOP 2014
Vaadin Introduction at OOP 2014
Johannes Eriksson
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
guileen
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
Dart, Darrt, Darrrt
Dart, Darrt, DarrrtDart, Darrt, Darrrt
Dart, Darrt, Darrrt
Jana Moudrá
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9
tomaspavelka
 

Semelhante a Ruby on Rails 3.1: Let's bring the fun back into web programing (20)

Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
When To Use Ruby On Rails
When To Use Ruby On RailsWhen To Use Ruby On Rails
When To Use Ruby On Rails
 
Ruby On Rails Introduction
Ruby On Rails IntroductionRuby On Rails Introduction
Ruby On Rails Introduction
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
 
Opa hackathon
Opa hackathonOpa hackathon
Opa hackathon
 
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
 
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
SoTWLG Intro to Code Bootcamps 2016 (Roger Nesbitt)
 
Vaadin Introduction at OOP 2014
Vaadin Introduction at OOP 2014Vaadin Introduction at OOP 2014
Vaadin Introduction at OOP 2014
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
Why Nodejs Guilin Shanghai
Why Nodejs Guilin ShanghaiWhy Nodejs Guilin Shanghai
Why Nodejs Guilin Shanghai
 
Why Node.js
Why Node.jsWhy Node.js
Why Node.js
 
Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3Prototyping w/HTML5 and CSS3
Prototyping w/HTML5 and CSS3
 
Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous Merb
 
EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008EuRuKo JRuby Talk 2008
EuRuKo JRuby Talk 2008
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
C#7, 7.1, 7.2, 7.3 e C# 8
C#7, 7.1, 7.2, 7.3 e C# 8C#7, 7.1, 7.2, 7.3 e C# 8
C#7, 7.1, 7.2, 7.3 e C# 8
 
Dart, Darrt, Darrrt
Dart, Darrt, DarrrtDart, Darrt, Darrrt
Dart, Darrt, Darrrt
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
Migrating To Ruby1.9
Migrating To Ruby1.9Migrating To Ruby1.9
Migrating To Ruby1.9
 
UIWebViewでつくるUI
UIWebViewでつくるUIUIWebViewでつくるUI
UIWebViewでつくるUI
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Ruby on Rails 3.1: Let's bring the fun back into web programing

  • 1. presents Ruby on Rails 3.1 Let’s bring the fun back to web programming! Bozhidar Batsov Technical Lead
  • 3. Many programmers are not particularly happy
  • 4. It's the question that drives us, Neo. It's the question that brought you here. You know the question, just as I did. What is the question?
  • 5. How can I be be one happy (web) programmer?
  • 6.
  • 7.
  • 8. VS. VS.
  • 9. VS. VS.
  • 10.
  • 11. This PHP code is so clean and elegantly solves the problem at hand. Nobody, Never
  • 12. PHP 0 10 20 30 40 50 60 70 80 90 100 OOP FP Performance Productivity Fun
  • 13.
  • 14.
  • 15. The Zen of Python There should be one – and preferably only one – obvious way to do it.
  • 16. Python 0 10 20 30 40 50 60 70 80 90 100 OOP FP Performance Productivity Fun
  • 17.
  • 18. The Web framework for perfectionists with deadlines.
  • 19. 2007
  • 20.
  • 22. The goal of Ruby is to make programmers happy. I started out to make a programming language that would make me happy, and as a side effect it’s made many, many programmers happy. Especially Web developers. Yukihiro “Matz” Matsumoto, creator of Ruby
  • 23. Ruby 0 10 20 30 40 50 60 70 80 90 100 OOP FP Performance Productivity Fun
  • 24. PHP Python Ruby 0 10 20 30 40 50 60 70 80 90 100 OOP FP Performance Productivity Fun
  • 25. Startup Technologies 2011 30 27 24 21 18 15 12 9 6 JQuery 3 Django 0 Ruby on Rails
  • 26.
  • 28.
  • 29. “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
  • 30. “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
  • 31. “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
  • 32. “Rails is the killer app for Ruby.” Yukihiro Matsumoto, Creator of Ruby
  • 33. Convention over Configuration
  • 34. DRY (Don’t repeat yourself)
  • 35.
  • 36. Many view (template) options HTML + Erb Haml <div id="profile"> #profile <div class="left column"> .left.column <div id="date"><%= print_date %></div> #date= print_date <div id="address"><%= current_user.address %></div> #address= current_user.address </div> .right.column <div class="right column"> #email= current_user.email <div id="email"><%= current_user.email %></div> #bio= current_user.bio <div id="bio"><%= current_user.bio %></div> </div> </div>
  • 37. doctype html html head title Slim Core Example meta name="keywords" content="template language" body h1 Markup examples div id="content" class="example1" p Nest by indentation == yield - unless items.empty? table - for item in items do tr td = item.name td = item.price - else p | No items found. Please add some inventory. Thank you! div id="footer" | Copyright © 2010 Andrew Stone = render 'tracking_code' javascript: $(content).do_something();
  • 38. Testing in Rails is not optional!
  • 39. All the code is guilty until proven innocent!
  • 41. ActiveRecord class Page < ActiveRecord::Base has_many :page_images, :dependent => :destroy validates :title, :presence => true, :uniqueness => true validates :content, :presence => true validates :permalink, :presence => true, :uniqueness => true accepts_nested_attributes_for :page_images, :allow_destroy => true def to_param permalink end end
  • 42. XML Free development: adapter: postgresql database: mycoolproject host: localhost username: mycoolproject password: mycoolproject encoding: utf8 test: adapter: sqlite3 database: db/test.sqlite3 pool: 5 timeout: 5000
  • 43. UNIX Certified rails g (generate) rails c (console) rails db (dbconsole) rake bundle
  • 44. Agile
  • 47. Fo r k me on Git Hu b!
  • 48. Fantastic documentation RailsGuides (http://guide.rubyonrails.org) RailsCasts (http://railscasts.org) PragProg Ruby on Rails 3 Tutorial (http://ruby.railstutorial.org/)
  • 49. The Dark Art of Deployment
  • 50.
  • 51.
  • 53. $ heroku create --stack cedar $ git push heroku master $ heroku open $ heroku scale web=100 worker=50
  • 56. CoffeeScript # Assignment: number = 42 opposite = true # Conditions: number = -42 if opposite # Functions: square = (x) -> x * x # Arrays: list = [1, 2, 3, 4, 5] # Objects: math = root: Math.sqrt square: square cube: (x) -> x * square x # Splats: race = (winner, runners...) -> print winner, runners # Existence: alert "I knew it!" if elvis? # Array comprehensions: cubes = (math.cube num for num in list)
  • 57. JavaScript var cubes, list, math, num, number, opposite, race, square; var __slice = Array.prototype.slice; number = 42; opposite = true; if (opposite) number = -42; square = function(x) { return x * x; }; list = [1, 2, 3, 4, 5]; math = { root: Math.sqrt, square: square, cube: function(x) { return x * square(x); } }; race = function() { var runners, winner; winner = arguments[0], runners = 2 <= arguments.length ? __slice.call(arguments, 1) : []; return print(winner, runners); }; if (typeof elvis !== "undefined" && elvis !== null) alert("I knew it!"); cubes = (function() { var _i, _len, _results; _results = []; for (_i = 0, _len = list.length; _i < _len; _i++) { num = list[_i]; _results.push(math.cube(num)); } return _results; })();
  • 59. SASS $blue: #3bbfce; .content-navigation { $margin: 16px; border-color: #3bbfce; color: #2b9eab; .content-navigation { } border-color: $blue; color: .border { darken($blue, 9%); padding: 8px; } margin: 8px; border-color: #3bbfce; .border { } padding: $margin / 2; margin: $margin / 2; border-color: $blue; }
  • 60. table.hl { table.hl { margin: 2em 0; margin: 2em 0; td.ln { } text-align: right; table.hl td.ln { } text-align: right; } } li { li { font: { font-family: serif; family: serif; font-weight: bold; weight: bold; font-size: 1.2em; size: 1.2em; } } }
  • 61. @mixin table-base { #data { th { float: left; text-align: center; margin-left: 10px; font-weight: bold; } } #data th { td, th {padding: 2px} text-align: center; } font-weight: bold; } @mixin left($dist) { #data td, #data th { float: left; padding: 2px; margin-left: $dist; } } #data { @include left(10px); @include table-base; }
  • 62. .error { .error, .badError { border: 1px #f00; border: 1px #f00; background: #fdd; background: #fdd; } } .error.intrusion { .error.intrusion, font-size: 1.3em; .badError.intrusion font-weight: bold; { } font-size: 1.3em; .badError { font-weight: bold; @extend .error; } border-width: 3px; .badError { } border-width: 3px; }
  • 63. Always in motion the future is...
  • 64. Rails 4.0 targeting Ruby 1.9.2 expected in an year it will be the end of the world as we know it :-)