Your SlideShare is downloading. ×

Rails 3

2,212

Published on

A Quick Tour of some of the new Ruby on Rails 3 features, given march 8th 2010 on a rotterdam-rb.org meeting.

A Quick Tour of some of the new Ruby on Rails 3 features, given march 8th 2010 on a rotterdam-rb.org meeting.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,212
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
26
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Rails 3 A Quick Tour by @iain_nl
  • 2. disclaimer Any content of these slides might already be outdated, we're talking beta here...
  • 3. Contents
      • Philosophy
      • Code design
      • Modularity
      • ActiveSupport
      • ActiveModel
      • ActionController
      • Plugin API
      • Router
      • HTML safety
      • Bundler
      • Concerns
      • Conclusion
  • 4. 1. Philisophy
      • Rails merges with Merb
      • The Great Refactor TM
      • Sanity
      • Modular
      • Performance
  • 5. 2. Code Design
      • Namespaced config/application.rb
    • module MyApp
    •    class Application < Rails::Application
    •      # your config here
    •    end
    • end
      • Rack up  config.ru
    • require ::File.expand_path('../config/environment',  __FILE__)
    • run MyApp::Application
      • Clean boot process config/boot.rb
    • begin
    •    require File.expand_path('../../.bundle/environment', __FILE__)
    • rescue LoadError
    •    require 'rubygems'
    •    require 'bundler'
    •    Bundler.setup
    • end
  • 6. 3. Modularity
      • opt out config/application.rb
    • require &quot;rails/all&quot;
    • # require &quot;action_controller/railtie&quot;
    • # require &quot;action_mailer/railtie&quot;
    • # require &quot;active_resource/railtie&quot;
    • # require &quot;rails/test_unit/railtie&quot;
    • config.generators do |g|
    •    g.orm             :active_record
    •    g.template_engine :erb
    •    g.test_framework  :test_unit, :fixture => true
    • end
      • Generators rails generate
    • Erb:
    •    erb:controller
    •    erb:mailer
    •    erb:scaffold
    • Haml:
    •    haml:controller
    •    haml:mailer
    •    haml:scaffold
  • 7. 4. ActiveSupport
      • Cherry Picking!
    • require 'active_support/core_ext/array/wrap'
    • require 'active_support/core_ext/benchmark'
    • require 'active_support/core_ext/exception'
    • require 'active_support/core_ext/class/attribute_accessors'
    • require 'active_support/core_ext/object/to_param'
    • require 'active_support/core_ext/string/inflections'
    • module ActiveSupport
    •    module Cache
    •      # etc....
    •    end
    • end
  • 8. 5. ActiveModel
      • Modular and reusable
    • class PostPresenter
    •    include ActiveModel::Validations
    •    include ActiveModel::Dirty
    •    include ActiveModel::StateMachine
    • end
      • The integration API
    • class LintTest < ActiveModel::TestCase
    •    include ActiveModel::Lint::Tests
    •    def setup
    •      @model = Sequel::Document.new
    •    end
    • end
      • Cleaner Syntax
    • Article.where(&quot;published_at <= ?&quot;, Time.now).includes(:comments)
        • Railscast 202
  • 9. 6. ActionController
      • Inheritence and abstraction
      • Reusable modules
    • module ActionController
    •    class Base < Metal
    •      include AbstractController::Callbacks
    •      include AbstractController::Layouts
    •      include AbstractController::Translation
    •      include ActionController::Helpers
    •      include ActionController::UrlFor
    •      include ActionController::Redirecting
    •      include ActionController::Rendering
    •      include ActionController::Renderers::All
    • # etc...
  • 10. 7. Plugin API
      • Every Rails Component is a Rails plugin
      • Eat your own dog food
    • module ActiveRecord
    •    class Railtie < Rails::Railtie
    •      railtie_name :active_record
    •      config.generators.orm :active_record, :migration => true,
    •                                            :timestamps => true
    •      rake_tasks do
    •        load &quot;active_record/railties/databases.rake&quot;
    •      end
    •      initializer &quot;active_record.logger&quot; do
    •        ActiveRecord.base_hook { self.logger ||= ::Rails.logger }
    •      end
    •    end
    • end
  • 11. 8. Router
      • Exposes your Rack
    • MyApp::Application.routes do
    •    constraints :subdomain => &quot;support&quot; do
    •      match &quot;/foo/bar&quot;, :to => &quot;foo#bar&quot;
    •      match &quot;/baz&quot;, :to => MyOtherRackApp
    •    end
    • scope &quot;(/:locale)&quot; do
    • resources :users do
    • resources :posts
    • end
    • end
    • end
      • Railscast 203
  • 12. 9. HTML Safety
      • Our helpers:
        • h
        • raw
        • html_safe?
        • html_safe
      • ERb stringbuffer is aware of html safety
      • Railscast 204
  • 13. 10. Bundler
      • Gem dependencies
      • Calculate versions beforehand
      • Update your rvm and passenger
      • Rails independent
      • Railscast 201
    • source &quot;http://rubygems.org&quot;
    • gem &quot;rails&quot;, &quot;3.0.0.beta&quot;
    • gem &quot;cutting_edge_gem&quot;, :git => &quot;git://github.com/...&quot;
    • group :test do
    •    gem &quot;rspec&quot;, &quot;2.0.0.beta3&quot;
    •    gem &quot;cucumber&quot;
    • end
  • 14. 11. Concerns
      • Rails plugins or gems are broken by design
      • Backwards compatibility is gone
      • Many, many changes
      • Beta feels alpha
      • New source code has few comments
  • 15. 12. Conclusion
      • Looks great
      • Doesn't feel great yet
      • Play, but don't upgrade just yet
  • 16. The End Please, don't forget the guide

×