SlideShare ist ein Scribd-Unternehmen logo
1 von 53
Downloaden Sie, um offline zu lesen
Ruby NoName Podcast
     Propaganda sponsorship
Rails 3.1
Rails 3.1
2 years of development
    1234 commits
   321 Contributors
  243244 coffee caps
         1 dhh
Delivering Developers
      Happiness
HTTP Streaming
HTTP Streaming
Make your’s applications even faster
Browser start
processing CSS and JS
before you request DB
Yes, all DB requests
  actually in view
Yes, all DB requests
  actually in view
      But, who care?
Unicorn
listen 3000, :tcp_nopush => false
class PostsController
class PostsController
  stream
class PostsController
  stream :only => :index
class PostsController
 def index
   @posts = Post.cool_posts.all

 end
class PostsController
 def index
   @posts = Post.cool_posts.all
   render :stream => true
 end
<!DOCTYPE html>
<html>
<head>
  <title><%= yield :title %></title>
  ...
  ...
</head>
<body>



<% content_for :title, "Projects" %>
<%= yield :title %>




<% content_for :title, "Projects" %>
<%= yield :title %>




      @posts = Post.cool_posts




<% content_for :title, "Projects" %>
<%= yield :title %>




    @posts = Post.cool_posts




<% provide :title, "Projects" %>
D’oh
Rack::Cache
Rack::Cache
Middlewares that need
to manipulate the body
Middlewares that need
to manipulate the body
1.9.2 Only
   fibers
ActiveRecord
Identity Map
   by Emilio Tagua
user1 = User.find(1)
user2 = User.find(1)

user1 == user2 # => true
user1.object_id == user2.object_id # => true
config.active_record.identity_map = true
Does not track
associations :(
Post.has_many :comments, :dependent => :destroy

comment = @post.comments.first
comment.post = nil
comment.save

Post.destroy(@post.id)
Post.has_many :comments, :dependent => :destroy

comment = @post.comments.first
comment.post = nil
comment.save

Post.destroy(@post.id)




        comment will be
          destroyed
Prepared Statements
SELECT * FROM users WHERE id = 42;
SELECT * FROM users WHERE id = ?;
Works Prefect
 • SQLite
 • Postgres
          Complicated
• MySQL
Role-based
mass-assignment
  protection
class Post < ActiveRecord::Base
  attr_accessible :title
  attr_accessible :title, :user_id, :as => :admin
end
class Post < ActiveRecord::Base
   attr_accessible :title
   attr_accessible :title, :user_id, :as => :admin
 end




Post.update_attributes(params[:post], :as => :admin)
Callable in Scope
class Filter < Struct.new(:klass)
  def call(*args); end
end

module CategoryFilter
  def call(category, *args)
    klass.where(:category => args.shift)
    super(*args)
  end
end

class User < ActiveRecord::Base
  scope :combined, Filter.new(self).extend(NameFilter)
end
jQuery by default
RJS has been extracted
     out to a gem
force_ssl
authenticity_token
 custom handling or to omit the token
Deprecated
AR options hash

:conditions, :include, :joins,
:limit, :offset, :order,
:select, :readonly, :group,
:having, :from, :lock
green_items = Item.scoped_by_colour('orange')
Questions?

Weitere ähnliche Inhalte

Was ist angesagt?

MIKE Stack Introduction - MongoDB, io.js, KendoUI, and Express
MIKE Stack Introduction - MongoDB, io.js, KendoUI, and ExpressMIKE Stack Introduction - MongoDB, io.js, KendoUI, and Express
MIKE Stack Introduction - MongoDB, io.js, KendoUI, and ExpressCharlie Key
 
async/await in Swift
async/await in Swiftasync/await in Swift
async/await in SwiftPeter Friese
 
Javascript REST with Jester
Javascript REST with JesterJavascript REST with Jester
Javascript REST with JesterMike Bailey
 
Creative Web 2 - JavaScript
Creative Web 2 - JavaScript Creative Web 2 - JavaScript
Creative Web 2 - JavaScript Lukas Oppermann
 
Celery - A Distributed Task Queue
Celery - A Distributed Task QueueCelery - A Distributed Task Queue
Celery - A Distributed Task QueueDuy Do
 
Asynchronous Task Queues with Celery
Asynchronous Task Queues with CeleryAsynchronous Task Queues with Celery
Asynchronous Task Queues with CeleryKishor Kumar
 
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)NexThoughts Technologies
 
Ruby on Rails Security Updated (Rails 3) at RailsWayCon
Ruby on Rails Security Updated (Rails 3) at RailsWayConRuby on Rails Security Updated (Rails 3) at RailsWayCon
Ruby on Rails Security Updated (Rails 3) at RailsWayConheikowebers
 
Introduction To Ruby Watir (Web Application Testing In Ruby)
Introduction To Ruby Watir (Web Application Testing In Ruby)Introduction To Ruby Watir (Web Application Testing In Ruby)
Introduction To Ruby Watir (Web Application Testing In Ruby)Mindfire Solutions
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performanceYehuda Katz
 
Inversion Of Control
Inversion Of ControlInversion Of Control
Inversion Of ControlChad Hietala
 
How to write easy-to-test JavaScript
How to write easy-to-test JavaScriptHow to write easy-to-test JavaScript
How to write easy-to-test JavaScriptYnon Perek
 
An Introduction to Celery
An Introduction to CeleryAn Introduction to Celery
An Introduction to CeleryIdan Gazit
 

Was ist angesagt? (20)

No SQL with Kendo UI
No SQL with Kendo UI No SQL with Kendo UI
No SQL with Kendo UI
 
Sbt for mere mortals
Sbt for mere mortalsSbt for mere mortals
Sbt for mere mortals
 
MIKE Stack Introduction - MongoDB, io.js, KendoUI, and Express
MIKE Stack Introduction - MongoDB, io.js, KendoUI, and ExpressMIKE Stack Introduction - MongoDB, io.js, KendoUI, and Express
MIKE Stack Introduction - MongoDB, io.js, KendoUI, and Express
 
async/await in Swift
async/await in Swiftasync/await in Swift
async/await in Swift
 
Javascript REST with Jester
Javascript REST with JesterJavascript REST with Jester
Javascript REST with Jester
 
Creative Web 2 - JavaScript
Creative Web 2 - JavaScript Creative Web 2 - JavaScript
Creative Web 2 - JavaScript
 
Celery - A Distributed Task Queue
Celery - A Distributed Task QueueCelery - A Distributed Task Queue
Celery - A Distributed Task Queue
 
Asynchronous Task Queues with Celery
Asynchronous Task Queues with CeleryAsynchronous Task Queues with Celery
Asynchronous Task Queues with Celery
 
Examplecode
ExamplecodeExamplecode
Examplecode
 
Advanced Jquery
Advanced JqueryAdvanced Jquery
Advanced Jquery
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to Jquery
 
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
Grails Plugins(Console, DB Migration, Asset Pipeline and Remote pagination)
 
Ruby on Rails Security Updated (Rails 3) at RailsWayCon
Ruby on Rails Security Updated (Rails 3) at RailsWayConRuby on Rails Security Updated (Rails 3) at RailsWayCon
Ruby on Rails Security Updated (Rails 3) at RailsWayCon
 
Introduction To Ruby Watir (Web Application Testing In Ruby)
Introduction To Ruby Watir (Web Application Testing In Ruby)Introduction To Ruby Watir (Web Application Testing In Ruby)
Introduction To Ruby Watir (Web Application Testing In Ruby)
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
 
Grails Plugins
Grails PluginsGrails Plugins
Grails Plugins
 
Inversion Of Control
Inversion Of ControlInversion Of Control
Inversion Of Control
 
How to write easy-to-test JavaScript
How to write easy-to-test JavaScriptHow to write easy-to-test JavaScript
How to write easy-to-test JavaScript
 
An Introduction to Celery
An Introduction to CeleryAn Introduction to Celery
An Introduction to Celery
 

Andere mochten auch

Проектирование интернет-сайтов и систем в Redsoft
Проектирование интернет-сайтов и систем в RedsoftПроектирование интернет-сайтов и систем в Redsoft
Проектирование интернет-сайтов и систем в RedsoftRedsoft
 
Windows Azure & NodeJS Microsoft SWIT 2012
Windows Azure & NodeJS Microsoft SWIT 2012 Windows Azure & NodeJS Microsoft SWIT 2012
Windows Azure & NodeJS Microsoft SWIT 2012 Dmytro Mindra
 
Серверный JavaScript: NodeJS и CouchDB
Серверный JavaScript: NodeJS и CouchDBСерверный JavaScript: NodeJS и CouchDB
Серверный JavaScript: NodeJS и CouchDBStepan Stolyarov
 
Повышаем отказоустойчивость без дорогих решений
Повышаем отказоустойчивость без дорогих решенийПовышаем отказоустойчивость без дорогих решений
Повышаем отказоустойчивость без дорогих решенийLenvendo
 
«Мой сосед Легаси», Сергей Федоров, Evil Martians
«Мой сосед Легаси», Сергей Федоров, Evil Martians«Мой сосед Легаси», Сергей Федоров, Evil Martians
«Мой сосед Легаси», Сергей Федоров, Evil Martiansit-people
 
Гибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSSГибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSSEcommerce Solution Provider SysIQ
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 

Andere mochten auch (9)

new JavaScript
new JavaScriptnew JavaScript
new JavaScript
 
Проектирование интернет-сайтов и систем в Redsoft
Проектирование интернет-сайтов и систем в RedsoftПроектирование интернет-сайтов и систем в Redsoft
Проектирование интернет-сайтов и систем в Redsoft
 
Windows Azure & NodeJS Microsoft SWIT 2012
Windows Azure & NodeJS Microsoft SWIT 2012 Windows Azure & NodeJS Microsoft SWIT 2012
Windows Azure & NodeJS Microsoft SWIT 2012
 
Enterprise Agile
Enterprise AgileEnterprise Agile
Enterprise Agile
 
Серверный JavaScript: NodeJS и CouchDB
Серверный JavaScript: NodeJS и CouchDBСерверный JavaScript: NodeJS и CouchDB
Серверный JavaScript: NodeJS и CouchDB
 
Повышаем отказоустойчивость без дорогих решений
Повышаем отказоустойчивость без дорогих решенийПовышаем отказоустойчивость без дорогих решений
Повышаем отказоустойчивость без дорогих решений
 
«Мой сосед Легаси», Сергей Федоров, Evil Martians
«Мой сосед Легаси», Сергей Федоров, Evil Martians«Мой сосед Легаси», Сергей Федоров, Evil Martians
«Мой сосед Легаси», Сергей Федоров, Evil Martians
 
Гибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSSГибкость и Структурированность Oбъектно Oриентированноя CSS
Гибкость и Структурированность Oбъектно Oриентированноя CSS
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Ähnlich wie Timothy N. Tsvetkov, Rails 3.1

Ruby on rails
Ruby on rails Ruby on rails
Ruby on rails Mohit Jain
 
Rails Concurrency Gotchas
Rails Concurrency GotchasRails Concurrency Gotchas
Rails Concurrency Gotchasmarcostoledo
 
More to RoC weibo
More to RoC weiboMore to RoC weibo
More to RoC weiboshaokun
 
Introduction to Active Record at MySQL Conference 2007
Introduction to Active Record at MySQL Conference 2007Introduction to Active Record at MySQL Conference 2007
Introduction to Active Record at MySQL Conference 2007Rabble .
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Railsrstankov
 
Rails World 2023: Powerful Rails Features You Might Not Know
Rails World 2023: Powerful Rails Features You Might Not KnowRails World 2023: Powerful Rails Features You Might Not Know
Rails World 2023: Powerful Rails Features You Might Not KnowChris Oliver
 
Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Rabble .
 
ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2RORLAB
 
Intro to Rails ActiveRecord
Intro to Rails ActiveRecordIntro to Rails ActiveRecord
Intro to Rails ActiveRecordMark Menard
 
Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010Plataformatec
 
Rails 3 (beta) Roundup
Rails 3 (beta) RoundupRails 3 (beta) Roundup
Rails 3 (beta) RoundupWayne Carter
 
Tame Accidental Complexity with Ruby and MongoMapper
Tame Accidental Complexity with Ruby and MongoMapperTame Accidental Complexity with Ruby and MongoMapper
Tame Accidental Complexity with Ruby and MongoMapperGiordano Scalzo
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redisDvir Volk
 
Pourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirentPourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirentNicolas Ledez
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 

Ähnlich wie Timothy N. Tsvetkov, Rails 3.1 (20)

Ruby on rails
Ruby on rails Ruby on rails
Ruby on rails
 
Rails Concurrency Gotchas
Rails Concurrency GotchasRails Concurrency Gotchas
Rails Concurrency Gotchas
 
More to RoC weibo
More to RoC weiboMore to RoC weibo
More to RoC weibo
 
Introduction to Active Record at MySQL Conference 2007
Introduction to Active Record at MySQL Conference 2007Introduction to Active Record at MySQL Conference 2007
Introduction to Active Record at MySQL Conference 2007
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
 
Rails World 2023: Powerful Rails Features You Might Not Know
Rails World 2023: Powerful Rails Features You Might Not KnowRails World 2023: Powerful Rails Features You Might Not Know
Rails World 2023: Powerful Rails Features You Might Not Know
 
Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007Introduction to Active Record - Silicon Valley Ruby Conference 2007
Introduction to Active Record - Silicon Valley Ruby Conference 2007
 
ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2ActiveRecord Query Interface (2), Season 2
ActiveRecord Query Interface (2), Season 2
 
Intro to Rails ActiveRecord
Intro to Rails ActiveRecordIntro to Rails ActiveRecord
Intro to Rails ActiveRecord
 
SOLID Ruby, SOLID Rails
SOLID Ruby, SOLID RailsSOLID Ruby, SOLID Rails
SOLID Ruby, SOLID Rails
 
Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
Active record(1)
Active record(1)Active record(1)
Active record(1)
 
Rails 3 (beta) Roundup
Rails 3 (beta) RoundupRails 3 (beta) Roundup
Rails 3 (beta) Roundup
 
Tame Accidental Complexity with Ruby and MongoMapper
Tame Accidental Complexity with Ruby and MongoMapperTame Accidental Complexity with Ruby and MongoMapper
Tame Accidental Complexity with Ruby and MongoMapper
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
 
Pourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirentPourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirent
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 

Timothy N. Tsvetkov, Rails 3.1