Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Rails 2.0
“evolution, not revolution”
Rails 2.0 Overview
           RESTful web architectures

         some small feature maturations

removal of features determined to be not essential
Action Pack
ActionController + ActionView
Multiview
“Machine-Gunning .rhtml and .rxml”

    (action.mimetype.renderer)
             show.html.erb
           index.atom.builder
            edit.iphone.haml
Partial Layouts
Partial Layouts
Routing Resources
Routing Namespaces




         link_to ‘variants’,
admin_product_variants_url(@product)

   /admin/products/:product_id/variants
Record Identification
           redirect_to(person)
     link_to(person.name, person)
            form_for(person)
HTTP Authentication
authenticate_or_request_with_http_basic
Exception Handling
controllers/application.rb




             rescue_from
Atom Feed Helper
Stolen from the DHH announcement
Mime::Type Predicates
     controller.request.format.html?
     controller.request.format.xml?
Performance
   Asset Servers
   Asset Caching
Cookie Based Sessions
most browsers will only make up
to two simultaneous connections
       to any one domain


       Asset Servers
config/environment.rb




             Asset Servers
config/environment.rb




              Asset Servers
      will always use the same server for a single file
Asset Caching
Cookie Based Sessions
example stolen from ryan daigle




Cookie Sessions Security
Security
 CSRF Protection
TextHelper#sanitize
HTTP only cookies
CSRF Protection
Active Resource
Short Overview of Resources
A consumer of RESTful resources



     Active Resource
A consumer of RESTful resources
     As ActiveRecord is a consumer of
       relational database resources


     Active Resource
ActiveResource Models
Active Resource Actions
                 Http REST   request
Model request                          Request URI         Response
                 operation    body

   find(id)         GET         n/a     /people/id.xml         <XML>


                                                              Status:
 save (update)     PUT       <XML>     /people/id.xml
                                                             200 OK


                                                            Location:
 save (create)     POST      <XML>        /people         http://x/people/id.xml



                                                              Status:
   destroy        DELETE       n/a     /people/id.xml
                                                             200 OK

      list         GET         n/a        /people             <XML>


                                                        credit: ryan diagle
demo
Active Record
Validations
:allow_blank
validates_numericality
:allow_blank
validates_numericality
Sexy Migrations
“Cold Shower” Migrations
Err Sexy Migrations
Rails 2.0 Sexy
4 fewer lines + rails programmers == sexy
References
Query Cache
Query Cache Logging
Disabling the Query
       Cache
Fixtures
    Foxy Fixtures
 Collection Fixtures
Fixture Performance
conferences.yml




places.yml




             Foxy Fixtures
conferences.yml




places.yml




             Foxy Fixtures
Was




        Now




Collection Fixtures
Data Exchange
 to_xml, from_xml
 to_json, from_json
/conferences/show/1.js
to_json
to_xml
Other Stuff
Rails 2.0 Presentation
rake
rake notes
rake notes
rake notes
rake db
  rake db:create
rake db:create:all
   rake db:drop
 rake db:drop:all
   rake db:reset
 rake db:rollback
 rake db:version
rake routes
Rails 2.0 Presentation
Rails 2.0 Presentation
rake routes
route name, HTTP method, route path, route requirements
Rails 2.0 Presentation
Rails 2.0 Presentation
Rails 2.0 Presentation
Rails 2.0 Presentation
helper :all
rails my_new_app
Request Profiler
               RubyProf Wrapper

./script/performance/request -n 10 login_session.rb
/config/initializers/
initializers directory
initializers directory
initializers directory
config/preinitializer.rb
 loaded before the environment files
Scaffolding
        ./script/generate scaffold conference
name:string description:text start_date:date end_date:date
Resourceful Scaffolding
Breakpoints
gem install ruby-debug
add ‘debugger’ to code
./script/server -u
demo
www.datanoise.com/ruby-debug
Upgrading to 2.0
Deprecations
with_scope
Components
Pagination
Object Transactions
http://code.bitsweat.net/svn/object_transactions/
ActionWebService
    ActiveResource
syntax changes
  @params           params[]
  @session          session[]
   @flash              flash[]
  @request          request[]
    @env              env[]
   find_all           find(:all)
  find_first          find(:first)
render_partial    render :partial
:post => true    :method => :post
start_form_tag
end_form_tag


form_for do
end
start_form_tag
end_form_tag


form_tag
</form>
Extracting to Plugins
     and Gems
            acts_as
       some js helpers
  commercial database adapters
./script/plugin install
   acts_as_list
   acts_as_nested_set
   acts_as_tree
   auto_complete
   in_place_editing
gem install
activerecord-X-adapter
   --source http://gems.rubyonrails.com

               firebird
             frontbase
              informix
             openbase
               oracle
             sqlserver
               sybase
Upgrade Process

 gem install rails -y
Resources
•   Peepcode Rails2 PDF - Ryan Daigle ($9)
•   http://weblog.rubyonrails.org
    •   /2007/12/7/rails-2-0-it-s-done


•   http://ryandaigle.com
    •   /articles/2007/12/7/rails-2-0-final-released-summary-of-features

•   http://www.slashdotdash.net
    •   /articles/2007/12/03/rails-2-upgrade-notes
Thanks!
noesbueno.org/rails2
Work with me @
         http://www.reactrix.com/careers.php
                 schacon@gmail.com



        Sr. Web Developer

    Linux Systems Administrator

  Sr. Game/Interaction Programmer

     Computer Vision Engineer

More Related Content

Rails 2.0 Presentation