nick sieger-exploring rails 3 through choices
DESCRIPTION
One of the most eagerly anticipated aspects of the fast-approaching Rails 3 release is its inherent modularity, and how that modularity gives the application developer more choice. We'll start with a tour of some of the headlining differences between Rails 2 and 3, and then put Rails 3's internal architecture to the test by demonstrating how to plug in some non-standard standard components, including an example of how to wire in a Java library using JRuby.TRANSCRIPT
![Page 2: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/2.jpg)
Nick
Sunday, March 21, 2010
![Page 3: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/3.jpg)
@
Sunday, March 21, 2010
![Page 4: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/4.jpg)
EY Cloud
Sunday, March 21, 2010
![Page 5: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/5.jpg)
EY Open Source
Rubinius Ruby 1.8.6
JRubyRails
Sunday, March 21, 2010
![Page 6: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/6.jpg)
Topic
Sunday, March 21, 2010
![Page 7: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/7.jpg)
3
Sunday, March 21, 2010
![Page 8: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/8.jpg)
Sunday, March 21, 2010
![Page 9: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/9.jpg)
Confession
Sunday, March 21, 2010
![Page 10: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/10.jpg)
I’m not a web developer
Sunday, March 21, 2010
![Page 11: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/11.jpg)
Sunday, March 21, 2010
![Page 12: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/12.jpg)
HTML
CSSJavaScript
Ruby
JSON
XML
SQL
HTTPTCP/IP
DNS
Apache
NginxFCGI Memcached
Sunday, March 21, 2010
![Page 13: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/13.jpg)
HTML
CSSJavaScript
Ruby
JSON
XML
SQL
HTTPTCP/IP
DNS
Apache
NginxFCGI Memcached
Sunday, March 21, 2010
![Page 14: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/14.jpg)
=Sunday, March 21, 2010
![Page 15: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/15.jpg)
Rubyin 2010
Sunday, March 21, 2010
![Page 16: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/16.jpg)
Sunday, March 21, 2010
![Page 17: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/17.jpg)
Sunday, March 21, 2010
![Page 18: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/18.jpg)
Ruby VMs
Sunday, March 21, 2010
![Page 19: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/19.jpg)
Ruby 1.8almost seven years old!
Sunday, March 21, 2010
![Page 20: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/20.jpg)
Ruby 1.9.2August 2010
Sunday, March 21, 2010
![Page 21: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/21.jpg)
JRuby 1.5April 2010
Sunday, March 21, 2010
![Page 22: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/22.jpg)
Rubinius 1.0Q2 2010
Sunday, March 21, 2010
![Page 23: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/23.jpg)
Ruby 2.0Let the prognostication begin
Sunday, March 21, 2010
![Page 24: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/24.jpg)
Sunday, March 21, 2010
![Page 25: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/25.jpg)
Sunday, March 21, 2010
![Page 26: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/26.jpg)
Sunday, March 21, 2010
![Page 27: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/27.jpg)
Sunday, March 21, 2010
![Page 28: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/28.jpg)
Sunday, March 21, 2010
![Page 29: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/29.jpg)
iSunday, March 21, 2010
![Page 30: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/30.jpg)
paralyzed bychoice
Sunday, March 21, 2010
![Page 31: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/31.jpg)
Sunday, March 21, 2010
![Page 32: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/32.jpg)
Sunday, March 21, 2010
![Page 33: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/33.jpg)
Sunday, March 21, 2010
![Page 34: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/34.jpg)
opinionated software
Sunday, March 21, 2010
![Page 35: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/35.jpg)
making choices
Sunday, March 21, 2010
![Page 36: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/36.jpg)
Sunday, March 21, 2010
![Page 37: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/37.jpg)
6 years later...
Sunday, March 21, 2010
![Page 38: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/38.jpg)
Sunday, March 21, 2010
![Page 39: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/39.jpg)
Sunday, March 21, 2010
![Page 40: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/40.jpg)
Sunday, March 21, 2010
![Page 41: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/41.jpg)
Rails 3highlights
Sunday, March 21, 2010
![Page 42: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/42.jpg)
Rails command$ rails newapp create create README create .gitignore create Rakefile create config.ru create Gemfile create app create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/models create app/views/layouts create config ...
Sunday, March 21, 2010
![Page 43: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/43.jpg)
Options$ rails -hUsage: rails APP_PATH [options]
Options: ... -O, [--skip-activerecord] # Skip ActiveRecord files -T, [--skip-testunit] # Skip TestUnit files -J, [--skip-prototype] # Skip Prototype files
Sunday, March 21, 2010
![Page 44: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/44.jpg)
Script
script/serverscript/generatescript/console
script/rails sscript/rails gscript/rails c
rails serverrails generaterails console
Sunday, March 21, 2010
![Page 45: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/45.jpg)
Layout
Sunday, March 21, 2010
![Page 46: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/46.jpg)
Classes
class MyController < ApplicationControllerend
class MyModel < ActiveRecord::Baseend
Sunday, March 21, 2010
![Page 47: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/47.jpg)
Unobtrusive JavaScript
Sunday, March 21, 2010
![Page 48: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/48.jpg)
JavaScript: R2link_to "Delete Image", @image, :confirm => "Are you sure?", :method => :delete
<a href="/images/9" onclick="if (confirm('Are you sure?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit(); };return false;">Delete Image</a>
Sunday, March 21, 2010
![Page 49: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/49.jpg)
JavaScript: R3
<a href="/images/9" rel="nofollow" data-method="delete" data-confirm="Are you sure?">Delete Image</a>
link_to "Delete Image", @image, :confirm => "Are you sure?", :method => :delete
Sunday, March 21, 2010
![Page 50: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/50.jpg)
XSS Safety
Sunday, March 21, 2010
![Page 51: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/51.jpg)
XSS Safety: R2
<%= h safe_value %>
<%= unsafe_value %>
Sunday, March 21, 2010
![Page 52: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/52.jpg)
XSS Safety: R3
<%= safe_value %>
<%= raw unsafe_value %>
Sunday, March 21, 2010
![Page 53: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/53.jpg)
Routing
Sunday, March 21, 2010
![Page 54: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/54.jpg)
Routing: R2
map.connect 'products/:id', :controller => 'catalog', :action => 'view'
map.resources :products do |products| products.resources :comments products.resources :sales, :collection => { :recent => :get }end
Sunday, March 21, 2010
![Page 55: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/55.jpg)
Routing: R3
match 'products/:id' => 'catalog#view'
resources :products do resources :comments resources :sales do get :recent, :on => :collection endend
Sunday, March 21, 2010
![Page 56: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/56.jpg)
More
• Cleaner ActionMailer
• ActiveRecord lazy queries
• ...
Sunday, March 21, 2010
![Page 57: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/57.jpg)
First OnlineRailsConf
http://bit.ly/online-railsconf-slides
Sunday, March 21, 2010
![Page 58: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/58.jpg)
APIs as Glue
Sunday, March 21, 2010
![Page 59: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/59.jpg)
Railties
Sunday, March 21, 2010
![Page 60: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/60.jpg)
The Extension APIfor Rails
Sunday, March 21, 2010
![Page 61: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/61.jpg)
Decouplinghttp://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/
Sunday, March 21, 2010
![Page 62: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/62.jpg)
Decoupling
ActionView
ActionControllerActiveRecord
http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/
Sunday, March 21, 2010
![Page 63: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/63.jpg)
Decoupling
ActionViewActionController ActiveRecord
http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/
Sunday, March 21, 2010
![Page 64: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/64.jpg)
Decoupling
ActionViewActionController ActiveRecord
http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/
Sunday, March 21, 2010
![Page 65: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/65.jpg)
ActionDispatch
AbstractController
Decoupling
ActionViewActionController ActiveRecord
http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/
Sunday, March 21, 2010
![Page 66: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/66.jpg)
ActionDispatch
AbstractController
Decoupling
ActionViewActionController
View Context
ActiveRecord
http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/
Sunday, March 21, 2010
![Page 67: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/67.jpg)
ActionDispatch
AbstractController
Decoupling
ActionView
ActiveModel
ActionController
View Context
ActiveRecord
http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/
Sunday, March 21, 2010
![Page 68: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/68.jpg)
Encapsulatewhat varies
Sunday, March 21, 2010
![Page 69: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/69.jpg)
Railties:Configuration encapsulated
Sunday, March 21, 2010
![Page 70: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/70.jpg)
Initialization Generators
Rake Tasks Logging Events
Railtie Elements
Sunday, March 21, 2010
![Page 71: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/71.jpg)
Example
require 'rails/railtie'
class MemCacheClusterRailtie < Rails::Railtie initializer :setup_mem_cache_cluster do |app| app.config.cache_store = [ :mem_cache_store, 'cache1:11211', 'cache2:11211'] endend
Sunday, March 21, 2010
![Page 72: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/72.jpg)
Rails’ Railties
ActionController::Railtie
ActionDispatch::Railtie
ActiveRecord::Railtie
ActionMailer::Railtie
Sunday, March 21, 2010
![Page 73: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/73.jpg)
Rails::Railtie
Rails::Application
Sunday, March 21, 2010
![Page 74: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/74.jpg)
Init: Rails 2def process Rails.configuration = configuration
check_ruby_version install_gem_spec_stubs set_load_path add_gem_load_paths
require_frameworks set_autoload_paths add_plugin_load_paths load_environment preload_frameworks
initialize_encoding initialize_database
initialize_cache initialize_framework_caches
initialize_logger initialize_framework_logging
initialize_dependency_mechanism initialize_whiny_nils
initialize_time_zone initialize_i18n
initialize_framework_settings initialize_framework_views
initialize_metal
add_support_load_paths
check_for_unbuilt_gems
load_gems load_plugins
# pick up any gems that plugins depend on add_gem_load_paths load_gems check_gem_dependencies
# bail out if gems are missing - note that check_gem_dependencies will have # already called abort() unless $gems_rake_task is set return unless gems_dependencies_loaded
load_application_initializers
# the framework is now fully initialized after_initialize
# Setup database middleware after initializers have run initialize_database_middleware
# Prepare dispatcher callbacks and run 'prepare' callbacks prepare_dispatcher
# Routing must be initialized after plugins to allow the former to extend the routes initialize_routing
# Observers are loaded after plugins in case Observers or observed models are modified by plugins. load_observers
# Load view path cache load_view_paths
# Load application classes load_application_classes
# Disable dependency loading during request cycle disable_dependency_loading
# Flag initialized Rails.initialized = trueend
Sunday, March 21, 2010
![Page 75: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/75.jpg)
Init: Rails 2
def process Rails.configuration = configuration
check_ruby_version install_gem_spec_stubs set_load_path add_gem_load_paths
require_frameworks set_autoload_paths add_plugin_load_paths load_environment preload_frameworks
initialize_encoding initialize_database
initialize_cache initialize_framework_caches
initialize_logger initialize_framework_logging
initialize_dependency_mechanism initialize_whiny_nils
initialize_time_zone initialize_i18n
initialize_framework_settings initialize_framework_views
initialize_metal
add_support_load_paths
check_for_unbuilt_gems
load_gems load_plugins
# pick up any gems that plugins depend on add_gem_load_paths load_gems check_gem_dependencies
# bail out if gems are missing - note that check_gem_dependencies will have # already called abort() unless $gems_rake_task is set return unless gems_dependencies_loaded
load_application_initializers
# the framework is now fully initialized after_initialize
# Setup database middleware after initializers have run initialize_database_middleware
# Prepare dispatcher callbacks and run 'prepare' callbacks prepare_dispatcher
# Routing must be initialized after plugins to allow the former to extend the routes initialize_routing
# Observers are loaded after plugins in case Observers or observed models are modified by plugins. load_observers
# Load view path cache load_view_paths
# Load application classes load_application_classes
# Disable dependency loading during request cycle disable_dependency_loading
# Flag initialized Rails.initialized = trueend
Sunday, March 21, 2010
![Page 76: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/76.jpg)
Init: Rails 3
class Rails::Application def initialize! run_initializers(self) self endend
Sunday, March 21, 2010
![Page 77: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/77.jpg)
rails newapp --skip-activerecord
ActiveRecord::Railtie is not loaded
No AR-related config or generators
Sunday, March 21, 2010
![Page 78: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/78.jpg)
• Modify configuration/init
• Add Rake tasks
• Add generators
Use Railtie to:
Sunday, March 21, 2010
![Page 79: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/79.jpg)
Rack
• Deserves a talk by itself
• HTTP request pipeline API
• See Ryan Tomayko’s slides from Online RailsConf
Sunday, March 21, 2010
![Page 80: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/80.jpg)
ActiveModel
Sunday, March 21, 2010
![Page 81: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/81.jpg)
codifies contractbetween
controllerand model
Sunday, March 21, 2010
![Page 82: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/82.jpg)
class Model def to_model; ...; end def to_key; ...; end def to_param; ...; end def valid?; ...; end def persisted?; ...; end def self.model_name; ...; end def errors; ...; endend
Contract
Sunday, March 21, 2010
![Page 83: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/83.jpg)
class ModelLintTest < Test::Unit::TestCase def setup @model = Model.new end
include ActiveModel::Lint::Testsend
Sunday, March 21, 2010
![Page 84: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/84.jpg)
Validations
class SimpleModel include ActiveModel::Validations
# => Model#valid?, Model#errors # plus validation frameworkend
Sunday, March 21, 2010
![Page 85: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/85.jpg)
class IceCream include ActiveModel::Validations attr_accessor :flavour validates_presence_of :flavourend
ic = IceCream.newic.valid? # => falseic.errors.full_messages # => ["Flavour can't be blank"]
ic.flavour = "vanilla"ic.valid? # => true
Sunday, March 21, 2010
![Page 86: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/86.jpg)
ActiveModel::Callbacks - before/after hooksActiveModel::Dirty - dirty attribute trackingActiveModel::Errors - #errorsActiveModel::Serialization - #to_xml, #to_json, etc.ActiveModel::Translation - I18n for model attributesActiveModel::Validations - Full validations framework
See ActiveModel RDoc comments for more info
AMo Modules
Sunday, March 21, 2010
![Page 87: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/87.jpg)
Putting it together
Sunday, March 21, 2010
![Page 88: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/88.jpg)
3
JRuby
Sunday, March 21, 2010
![Page 89: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/89.jpg)
Explore Rails 3for yourself!
Sunday, March 21, 2010
![Page 90: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/90.jpg)
Photo Credits
• http://www.flickr.com/photos/henrybloomfield/2615837191/
• http://www.flickr.com/photos/mountainbread/2528179567/
• http://www.flickr.com/photos/aai/3712515230/
• http://www.flickr.com/photos/mikeschinkel/2703438152/
Sunday, March 21, 2010
![Page 91: Nick Sieger-Exploring Rails 3 Through Choices](https://reader034.vdocuments.us/reader034/viewer/2022052522/554f77ebb4c9052a518b4869/html5/thumbnails/91.jpg)
Sunday, March 21, 2010