0
Ruby NoName Podcast     Propaganda sponsorship
Rails 3.1
Rails 3.12 years of development    1234 commits   321 Contributors  243244 coffee caps         1 dhh
Delivering Developers      Happiness
HTTP Streaming
HTTP StreamingMake your’s applications even faster
Browser startprocessing CSS and JSbefore 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 needto manipulate the body
Middlewares that needto manipulate the body
1.9.2 Only   fibers
ActiveRecordIdentity Map   by Emilio Tagua
user1 = User.find(1)user2 = User.find(1)user1 == user2 # => trueuser1.object_id == user2.object_id # => true
config.active_record.identity_map = true
Does not trackassociations :(
Post.has_many :comments, :dependent => :destroycomment = @post.comments.firstcomment.post = nilcomment.savePost.destroy(@p...
Post.has_many :comments, :dependent => :destroycomment = @post.comments.firstcomment.post = nilcomment.savePost.destroy(@p...
Prepared Statements
SELECT * FROM users WHERE id = 42;
SELECT * FROM users WHERE id = ?;
Works Prefect • SQLite • Postgres          Complicated• MySQL
Role-basedmass-assignment  protection
class Post < ActiveRecord::Base  attr_accessible :title  attr_accessible :title, :user_id, :as => :adminend
class Post < ActiveRecord::Base   attr_accessible :title   attr_accessible :title, :user_id, :as => :admin endPost.update_...
Callable in Scope
class Filter < Struct.new(:klass)  def call(*args); endendmodule CategoryFilter  def call(category, *args)    klass.where(...
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?
Timothy N. Tsvetkov, Rails 3.1
Timothy N. Tsvetkov, Rails 3.1
Timothy N. Tsvetkov, Rails 3.1
Timothy N. Tsvetkov, Rails 3.1
Upcoming SlideShare
Loading in...5
×

Timothy N. Tsvetkov, Rails 3.1

1,173

Published on

Timothy N. Tsvetkov & Gregory Mann's keynote on Rails 3.1 new features.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,173
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Timothy N. Tsvetkov, Rails 3.1"

  1. 1. Ruby NoName Podcast Propaganda sponsorship
  2. 2. Rails 3.1
  3. 3. Rails 3.12 years of development 1234 commits 321 Contributors 243244 coffee caps 1 dhh
  4. 4. Delivering Developers Happiness
  5. 5. HTTP Streaming
  6. 6. HTTP StreamingMake your’s applications even faster
  7. 7. Browser startprocessing CSS and JSbefore you request DB
  8. 8. Yes, all DB requests actually in view
  9. 9. Yes, all DB requests actually in view But, who care?
  10. 10. Unicorn
  11. 11. listen 3000, :tcp_nopush => false
  12. 12. class PostsController
  13. 13. class PostsController stream
  14. 14. class PostsController stream :only => :index
  15. 15. class PostsController def index @posts = Post.cool_posts.all end
  16. 16. class PostsController def index @posts = Post.cool_posts.all render :stream => true end
  17. 17. <!DOCTYPE html><html><head> <title><%= yield :title %></title> ... ...</head><body><% content_for :title, "Projects" %>
  18. 18. <%= yield :title %><% content_for :title, "Projects" %>
  19. 19. <%= yield :title %> @posts = Post.cool_posts<% content_for :title, "Projects" %>
  20. 20. <%= yield :title %> @posts = Post.cool_posts<% provide :title, "Projects" %>
  21. 21. D’oh
  22. 22. Rack::Cache
  23. 23. Rack::Cache
  24. 24. Middlewares that needto manipulate the body
  25. 25. Middlewares that needto manipulate the body
  26. 26. 1.9.2 Only fibers
  27. 27. ActiveRecordIdentity Map by Emilio Tagua
  28. 28. user1 = User.find(1)user2 = User.find(1)user1 == user2 # => trueuser1.object_id == user2.object_id # => true
  29. 29. config.active_record.identity_map = true
  30. 30. Does not trackassociations :(
  31. 31. Post.has_many :comments, :dependent => :destroycomment = @post.comments.firstcomment.post = nilcomment.savePost.destroy(@post.id)
  32. 32. Post.has_many :comments, :dependent => :destroycomment = @post.comments.firstcomment.post = nilcomment.savePost.destroy(@post.id) comment will be destroyed
  33. 33. Prepared Statements
  34. 34. SELECT * FROM users WHERE id = 42;
  35. 35. SELECT * FROM users WHERE id = ?;
  36. 36. Works Prefect • SQLite • Postgres Complicated• MySQL
  37. 37. Role-basedmass-assignment protection
  38. 38. class Post < ActiveRecord::Base attr_accessible :title attr_accessible :title, :user_id, :as => :adminend
  39. 39. class Post < ActiveRecord::Base attr_accessible :title attr_accessible :title, :user_id, :as => :admin endPost.update_attributes(params[:post], :as => :admin)
  40. 40. Callable in Scope
  41. 41. class Filter < Struct.new(:klass) def call(*args); endendmodule CategoryFilter def call(category, *args) klass.where(:category => args.shift) super(*args) endendclass User < ActiveRecord::Base scope :combined, Filter.new(self).extend(NameFilter)end
  42. 42. jQuery by default
  43. 43. RJS has been extracted out to a gem
  44. 44. force_ssl
  45. 45. authenticity_token custom handling or to omit the token
  46. 46. Deprecated
  47. 47. AR options hash:conditions, :include, :joins,:limit, :offset, :order,:select, :readonly, :group,:having, :from, :lock
  48. 48. green_items = Item.scoped_by_colour(orange)
  49. 49. Questions?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×