10 Cool Things About Rails 2.3

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

1 comments

Comments 1 - 1 of 1 previous next Post a comment

Post a comment
Embed Video
Edit your comment Cancel

7 Favorites & 1 Group

10 Cool Things About Rails 2.3 - Presentation Transcript

  1. 10 cool things in Rails 2.3 Luke Francl
  2. Boots Faster in Development Empty Rails app (real time) time script/server -d Rails 2.2 Rails 2.3 1.461s 0.869s
  3. Boots Faster in Development n- no ! lly Empty Rails app (real time) fic ta nti time script/server -d To cie s Rails 2.2 Rails 2.3 1.461s 0.869s
  4. Support for Rails Engines Photo: Wikipedia
  5. Routing Improvements
  6. Routing Improvements RESTful routes use 50% less memory because formatted_* routes are no longer generated. Before: formatted_users_path('xml') formatted_users_path(:format => 'xml') Now: users_path(:format => 'xml')
  7. Routing Improvements Routes no longer inherit :only and :except. Before: map.resources :users, :only => :show do |user| user.resources :hobbies, :except => :none end Now: map.resources :users, :only => :show do |user| user.resources :hobbies end
  8. JSON Improvements
  9. JSON Improvements JSON keys are always quoted, per the spec. Before: {123 => 'abc'}.to_json => '{123: \"abc\"}' Now: {123 => 'abc'}.to_json => '{\"123\": \"abc\"}'
  10. JSON Improvements Unicode escape sequences are unescaped. Before: ActiveSupport::JSON.decode (\"{'hello': 'fa\\\\u00e7ade'}\") => {\"hello\"=>\"fa\\\\u00e7ade\"} Now: ActiveSupport::JSON.decode (\"{'hello': 'fa\\u00e7ade'}\") => {\"hello\"=>\"façade\"}
  11. Default Scopes default_scope :order => 'name asc' # will use default scope User.all # will use passed in order option. User.all(:order => 'name desc') puts User.all.map { |u| \"#{u.id} - #{u.name}\" } 3 - Alice 2 - Bob 1 - George
  12. Nested Transactions User.transaction do user = User.create(:name => 'Luke') User.transaction(:requires_new => true) do user.hobbies.create(:name => 'Knitting') raise ActiveRecord::Rollback(\"Oh noes!!!\") end end
  13. Asset Host Objects class SslAssetHost def call(source, request) if request.ssl? \"#{request.protocol}#{request.host_with_port}\" else \"#{request.protocol}assets.example.com\" end end end
  14. Override Timestamp Fields User.create(:name => \"Alice\", :created_at => 3.weeks.ago, :updated_at => 2.weeks.ago) => #<User id: 3, name: \"Alice\", created_at: \"2009-03-08 00:06:58\", updated_at: \"2009-03-15 00:06:58\">
  15. Nested Attributes... class User < ActiveRecord::Base has_many :hobbies, :dependent => :destroy accepts_nested_attributes_for :hobbies end user = User.create(:name => 'Stan', :hobbies_attributes => [{:name => 'Waterskiing'}, {:name => 'Hiking'}])
  16. ...and Forms <% form_for(@user) do |f| %> <%= f.label :name, \"User name:\" %> <%= f.text_field :name %> <h2>Hobbies</h2> <% f.fields_for(:hobbies) do |hf| %> <%= hf.label :name, \"Hobby name:\" %> <%= hf.text_field :name %> <% end %> <%= f.submit 'Create' %> <% end %>
  17. Rails Metal class UsersApi def self.call(env) if env['PATH_INFO'] =~ /^\\/users.js/ [200, {'Content-Type' => 'application/json'}, User.all.to_json] else # Return 404 to let Rails handle the request [404, {'Content-Type' => 'text/html'}, 'not found'] end end end
  18. Rails Metal \\m/ class UsersApi def self.call(env) if env['PATH_INFO'] =~ /^\\/users.js/ [200, {'Content-Type' => 'application/json'}, User.all.to_json] else # Return 404 to let Rails handle the request [404, {'Content-Type' => 'text/html'}, 'not found'] end end end
  19. Thanks! Blog post: http://railspikes.com/2009/3/30/10-cool-things-in-rails-23 Slides: http://slideshare.net/lukefrancl/10-cool-things-about-rails-23 Code: http://bitbucket.org/look/rails23-10coolfeatures/ Rails 2.3 Release Notes: http://guides.rubyonrails.org/2_3_release_notes.html

+ Luke FranclLuke Francl, 8 months ago

custom

4490 views, 7 favs, 12 embeds more stats

These are my slides for my presentation to the Ruby more

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 4490
    • 2225 on SlideShare
    • 2265 from embeds
  • Comments 1
  • Favorites 7
  • Downloads 51
Most viewed embeds
  • 2188 views on http://railspikes.com
  • 46 views on http://railsandruby.blogspot.com
  • 14 views on http://www.ccok.me
  • 3 views on http://i4y.jsfirm.cn
  • 3 views on http://structurallysoundtreehouse.com

more

All embeds
  • 2188 views on http://railspikes.com
  • 46 views on http://railsandruby.blogspot.com
  • 14 views on http://www.ccok.me
  • 3 views on http://i4y.jsfirm.cn
  • 3 views on http://structurallysoundtreehouse.com
  • 3 views on http://manhattan.assetbar.com
  • 3 views on http://structurallysoundtreehouse.blogspot.com
  • 1 views on http://www.tumblr.com
  • 1 views on http://97.gmodules.com
  • 1 views on http://www.noscetipsum.com
  • 1 views on http://yinkei.com
  • 1 views on https://railspikes.com

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories

Groups / Events