Rails 2.0 Presentation

  • View
    9.268

  • Download
    0

  • Category

    Business

Preview:

DESCRIPTION

These are the slides from my presentation on Rails 2.0 at the Silicon Valley Ruby on Rails Meetup on Dec 13.

Citation preview

Rails 2.0“evolution, not revolution”

Rails 2.0 OverviewRESTful web architectures

some small feature maturations

removal of features determined to be not essential

Action Pack

ActionController + ActionView

Multiview

show.html.erbindex.atom.builderedit.iphone.haml

“Machine-Gunning .rhtml and .rxml”

(action.mimetype.renderer)

Partial Layouts

Partial Layouts

Routing Resources

link_to ‘variants’, admin_product_variants_url(@product)

/admin/products/:product_id/variants

Routing Namespaces

Record Identification

redirect_to(person)link_to(person.name, person)

form_for(person)

HTTP Authentication

authenticate_or_request_with_http_basic

Exception Handling

rescue_from

controllers/application.rb

Atom Feed Helper

Stolen from the DHH announcement

Mime::Type Predicates

controller.request.format.html?controller.request.format.xml?

PerformanceAsset ServersAsset Caching

Cookie Based Sessions

Asset Servers

most browsers will only make up to two simultaneous connections

to any one domain

Asset Servers

config/environment.rb

Asset Servers

config/environment.rb

will always use the same server for a single file

Asset Caching

Cookie Based Sessions

Cookie Sessions Security

example stolen from ryan daigle

Security

CSRF Protection

TextHelper#sanitize

HTTP only cookies

CSRF Protection

Active Resource

Short Overview of Resources

Active Resource

A consumer of RESTful resources

Active Resource

A consumer of RESTful resourcesAs ActiveRecord is a consumer of

relational database resources

ActiveResource Models

Active Resource ActionsModel request Http REST

operation request

body Request URI Response

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

save (update) PUT <XML> /people/id.xmlStatus:

200 OK

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

destroy DELETE n/a /people/id.xmlStatus:

200 OK

list GET n/a /people <XML>

credit: ryan diagle

demo

Active Record

Validations

:allow_blankvalidates_numericality

:allow_blankvalidates_numericality

Sexy Migrations

“Cold Shower” Migrations

Err Sexy Migrations

Rails 2.0 Sexy4 fewer lines + rails programmers == sexy

References

Query Cache

Query Cache Logging

Disabling the Query Cache

FixturesFoxy Fixtures

Collection FixturesFixture Performance

Foxy Fixtures

conferences.yml

places.yml

Foxy Fixtures

conferences.yml

places.yml

Collection Fixtures

Now

Was

Data Exchange

to_xml, from_xmlto_json, from_json

to_xml

Other Stuff

rake

rake notes

rake notes

rake notes

rake db

rake db:createrake db:create:all

rake db:droprake db:drop:allrake db:reset

rake db:rollbackrake db:version

rake routes

rake routesroute name, HTTP method, route path, route requirements

helper :all

rails my_new_app

Request Profiler

./script/performance/request -n 10 login_session.rb

RubyProf Wrapper

/config/initializers/

initializers directory

initializers directory

initializers directory

config/preinitializer.rbloaded 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

Upgrading to 2.0

Deprecations

with_scope

Components

Pagination

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_tagend_form_tag

form_for doend

start_form_tagend_form_tag

form_tag</form>

Extracting to Plugins and Gems

acts_assome js helpers

commercial database adapters

./script/plugin install

acts_as_listacts_as_nested_setacts_as_treeauto_completein_place_editing

gem install activerecord-X-adapter

--source http://gems.rubyonrails.com

firebirdfrontbaseinformix

openbaseoracle

sqlserversybase

Upgrade Process

gem install rails -y

Thanks!noesbueno.org/rails2

Work with me @

Sr. Web Developer

Linux Systems Administrator

Sr. Game/Interaction Programmer

Computer Vision Engineer

http://www.reactrix.com/careers.phpschacon@gmail.com

Recommended