rails3: stepping off of the golden path

105
Rails3 step off of the golden path RailsConf2009 - matt aimonetti Wednesday, May 6, 2009

Upload: matt-aimonetti

Post on 15-Jul-2015

10.772 views

Category:

Technology


5 download

TRANSCRIPT

Rails3

step off ofthe golden path

RailsC

onf2009 - matt aim

onetti

Wednesday, May 6, 2009

WHO AM I?m a t t a i m o n e t t i

Wednesday, May 6, 2009

WHO AM I?m a t t a i m o n e t t i

“morally loose, cheese eating surrender monkey”

Wednesday, May 6, 2009

WHO AM I?m a t t a i m o n e t t i

“morally loose, cheese eating surrender monkey”Ted Han

Wednesday, May 6, 2009

WHO AM I?m a t t a i m o n e t t i

“morally loose, cheese eating surrender monkey”Ted Han

Ruby Addict

Wednesday, May 6, 2009

WHO AM I?m a t t a i m o n e t t i

“morally loose, cheese eating surrender monkey”Ted Han

Merb

Ruby Addict

Wednesday, May 6, 2009

WHO AM I?m a t t a i m o n e t t i

“morally loose, cheese eating surrender monkey”Ted Han

Merb Rails

Ruby Addict

Wednesday, May 6, 2009

WHO AM I?m a t t a i m o n e t t i

“morally loose, cheese eating surrender monkey”Ted Han

Merb Rails

MacRuby

Ruby Addict

Wednesday, May 6, 2009

Rails3

step off ofthe golden path

RailsC

onf2009 - matt aim

onetti

Wednesday, May 6, 2009

MERGEWednesday, May 6, 2009

Wednesday, May 6, 2009

Wednesday, May 6, 2009

Wednesday, May 6, 2009

RUBY

oscon 2003Wednesday, May 6, 2009

RUBY

Wednesday, May 6, 2009

RUBY

Wednesday, May 6, 2009

RUBY

Wednesday, May 6, 2009

Wednesday, May 6, 2009

Wednesday, May 6, 2009

RUBY ON RAILS

Convention over Configuration

Don't repeat yourself

Wednesday, May 6, 2009

LARGE ADOPTION

Wednesday, May 6, 2009

SCHISM

Wednesday, May 6, 2009

Performance

Agnosticism

Wednesday, May 6, 2009

Adobe

Wikimedia

sproutcore/Apple

AT&T/yellowpages.com

powerset/microsoft...

Wednesday, May 6, 2009

SPLIT RUBY COMMUNITY

...Wednesday, May 6, 2009

DRAMA

...Wednesday, May 6, 2009

SAT DOWN & TALKED

...Wednesday, May 6, 2009

DIFFERENT PERSPECTIVES

Wednesday, May 6, 2009

SAME GOAL

Wednesday, May 6, 2009

MERGEWednesday, May 6, 2009

Wednesday, May 6, 2009

Wednesday, May 6, 2009

WHAT DO YOU GET?

Wednesday, May 6, 2009

Wednesday, May 6, 2009

vaporware

Wednesday, May 6, 2009

WHAT ARE YOU GOING TO GET

improved performance

Wednesday, May 6, 2009

WHAT ARE YOU GOING TO GET

increased modularity

Wednesday, May 6, 2009

WHAT ARE YOU GOING TO GET

agnosticism

Wednesday, May 6, 2009

WHAT ARE YOU GOING TO GET

public API

Wednesday, May 6, 2009

WHAT ARE YOU GOING TO GET

mountable apps

Wednesday, May 6, 2009

WHAT DOES IT REALLY MEAN?

Rails 2

Wednesday, May 6, 2009

WHAT DOES IT REALLY MEAN?

Rails 3

Wednesday, May 6, 2009

CECI N’EST PAS LA RÉALITÉ

Rails 2

� �

assert_equal(true, AwesomeApp.success?)

html, xml, json, js

Wednesday, May 6, 2009

CECI N’EST PAS LA RÉALITÉ

Rails 2

� �

assert_equal(true, AwesomeApp.success?)

html, xml, json, js

ERB

Wednesday, May 6, 2009

CECI N’EST PAS LA RÉALITÉ

Rails 2

� �

assert_equal(true, AwesomeApp.success?)

html, xml, json, js

ERB

Wednesday, May 6, 2009

CECI N’EST PAS LA RÉALITÉ

Rails 2

� �

assert_equal(true, AwesomeApp.success?)

html, xml, json, js

ActiveRecord

ERB

Wednesday, May 6, 2009

CECI N’EST PAS LA RÉALITÉ

Rails 2

� �

assert_equal(true, AwesomeApp.success?)

html, xml, json, js

ActiveRecord

Test::Unit

ERB

Wednesday, May 6, 2009

RAILS 3 DEFAULT STACK

• ORM: ActiveRecord

• JS: Prototype

• Templating: ERB

• Testing: Test::Unit

Wednesday, May 6, 2009

RAILS 3 - DEFAULT STACK

� �

assert_equal(true, AwesomeApp.success?)

html, xml, json, js

Wednesday, May 6, 2009

RAILS 3 - DEFAULT STACK

� �

assert_equal(true, AwesomeApp.success?)

html, xml, json, js

ERB

Wednesday, May 6, 2009

RAILS 3 - DEFAULT STACK

� �

assert_equal(true, AwesomeApp.success?)

html, xml, json, js

ERB

Wednesday, May 6, 2009

RAILS 3 - DEFAULT STACK

� �

assert_equal(true, AwesomeApp.success?)

html, xml, json, js

ActiveRecord

ERB

Wednesday, May 6, 2009

RAILS 3 - DEFAULT STACK

� �

assert_equal(true, AwesomeApp.success?)

html, xml, json, js

ActiveRecord

Test::Unit

ERB

Wednesday, May 6, 2009

WHAAAT?

Wednesday, May 6, 2009

NO DRASTIC CHANGES FOR THE END USERS

Wednesday, May 6, 2009

RAILS WAY

Wednesday, May 6, 2009

RAILS WAYS

Wednesday, May 6, 2009

Wednesday, May 6, 2009

Wednesday, May 6, 2009

Wednesday, May 6, 2009

GAIN FLEXIBILTY

Wednesday, May 6, 2009

LESS OPINIONATEDWednesday, May 6, 2009

WE ARE NOT ALL THE SAMEWednesday, May 6, 2009

Wednesday, May 6, 2009

¿WHEN?

Wednesday, May 6, 2009

Use default stack?

Rails 3 default stack

Is there a reason not to use it?

Yis it a

question of taste?

Use the default stack and stop overthinking

things

NY

is it worth it?

Rails 3 custom stack

evaluate your requirements:templating, JS, ORM,

Performance

N

N

Y is it worth it?

Y

N

Wednesday, May 6, 2009

OPTIONS

Wednesday, May 6, 2009

JAVASCRIPT FRAMEWORKS

Wednesday, May 6, 2009

TEMPLATING ENGINES

Wednesday, May 6, 2009

OBJECT RELATION MAPPER

Wednesday, May 6, 2009

Databases

Object OrientedLanguages

scalar values

objectsdata

ORM

Wednesday, May 6, 2009

RAW SQL

SELECT * FROM BookWHERE price > 100.00ORDER BY title;

Wednesday, May 6, 2009

ACTIVERECORD

Book.all \ :conditions => ["price > ?", 100.00], :order => 'title'

Wednesday, May 6, 2009

DATAMAPPER

Book.all \ :price.gt => 100.00, :order => [:title.asc]

Wednesday, May 6, 2009

SEQUEL

Book.find{|b| b.price > 100.00}.order(:title)

Wednesday, May 6, 2009

COUCHREST

Book.by_price(:startkey => 100.01)

Wednesday, May 6, 2009

MANY MORE ORMS/DSLS

Wednesday, May 6, 2009

RUBY IS AWESOME

Wednesday, May 6, 2009

DATAMAPPER

Wednesday, May 6, 2009

DATAMAPPER

@parent = Parent.find_by_name("Matt")

@parent.children.each do |child| @parent.object_id.should == child.parent.object_idend

Wednesday, May 6, 2009

DATAMAPPER

@parent = Parent.find_by_name("Matt")

@parent.children.each do |child| @parent.object_id.should == child.parent.object_idend

Fails with ActiceRecord

Wednesday, May 6, 2009

DATAMAPPER

@parent = Parent.find_by_name("Matt")

@parent.children.each do |child| @parent.object_id.should == child.parent.object_idend

Fails with ActiceRecord

Passes with DataMapper

Wednesday, May 6, 2009

DATAMAPPER

does what ActiveRecord does...

but differently

Wednesday, May 6, 2009

DATAMAPPER

db drivers using 1 unified interface

Cop

yrig

ht -

Mer

b in

Act

ion

- M

anni

ng

Wednesday, May 6, 2009

DATAMAPPER

• procrastination as a value

• Lazy Loading

• Strategic Eager Loader

Wednesday, May 6, 2009

DATAMAPPER

students = Student.allstudents.each do |student| student.books.map{|b| b.name}end

Wednesday, May 6, 2009

ACTIVERECORD

SELECT * FROM "students" SELECT * FROM "books" WHERE ("books".student_id = 1)SELECT * FROM "books" WHERE ("books".student_id = 2)SELECT * FROM "books" WHERE ("books".student_id = 3)SELECT * FROM "books" WHERE ("books".student_id = X)

students = Student.allstudents.each do |student| student.books.map{|b| b.name}end

Wednesday, May 6, 2009

DATAMAPPER

students = Student.allstudents.each do |student| student.books.map{|b| b.name}end

SELECT "id", "name" FROM "students" ORDER BY "id"SELECT "id", "name", "student_id" FROM "books" WHERE ("student_id" IN (1, 2, 3, X)) ORDER BY "id"

Wednesday, May 6, 2009

MULTIPLE REPOSproduction: adapter: mysql encoding: utf8 database: production-app username: root password: top-s3ckrit host: localhost repositories: nightly_backup: adapter: sqlite3 database: shared/nightly.db weekly_backup: adapter: sqlite3 database: shared/weekly.db

Wednesday, May 6, 2009

MULTIPLE REPOS

Article.copy(:default, :nightly_backup, :created.gt => 1.day.ago )

Wednesday, May 6, 2009

MULTIPLE REPOSclass Page include DataMapper::Resource property :id, Serial property :name, String repository(:legacy) do property :name, String, :field => "title" endend

Wednesday, May 6, 2009

QUERY::PATH

Person.all("addresses.street.like" => "%street%" )

SELECT "people"."id", "people"."name" FROM "people"INNER JOIN "addresses" ON ("people"."id" = "addresses"."person_id")WHERE ("addresses"."street" LIKE '%street%')ORDER BY "people"."id"

Find all people with an address that has street in the street name

Wednesday, May 6, 2009

ADAPTERS

RDBMSfile system

IMAPSales Force

YAMLREST APIs

custom APIs...

Wednesday, May 6, 2009

SEQUEL

• Prepared Statements

• Sharding

• highly customizable SQL work

• high performance

Wednesday, May 6, 2009

HIBERNATE

• ActionORM

• JRuby

Wednesday, May 6, 2009

NON RDBMS SYSTEMS

• AppEngine::Datastore

• CouchDB with CouchRest or other DSL

• Redis, Tokyo Cabinet etc...

Wednesday, May 6, 2009

RAILS EXTREME

only for a few of you

Wednesday, May 6, 2009

CUSTOMIZE RAILS TO THE EXTREME

Wednesday, May 6, 2009

CREATE YOUR OWN RAILS

• define your own file structure

• define your own router DSL

• define your own ways to deal with requests

Wednesday, May 6, 2009

EXTEND ACTIONCONTROLER

class Presentation < ActionController::Http def index self.response_body = "Rails3 + MacRuby" endend Presentation.action(:index).call \ Rack::MockRequest.env_for("/railsconf10")

Wednesday, May 6, 2009

EXTEND ACTIONCONTROLER

def action(&blk) Class.new(ActionController::Http) do include ActionController::Renderer define_method(:xtreme, &blk) end.action(:xtreme)end run action do render "some_template"end

Wednesday, May 6, 2009

¿FUTURE?

Wednesday, May 6, 2009

+

+C o u c h D B

Wednesday, May 6, 2009

credits:http://www.flickr.com/photos/dotdoubledot/

Katsushika HokusaiDelacroixBenetton

http://www.rubyist.net/~matz/slides/oscon2003Matt Groening

http://www.flickr.com/photos/derricksphotos/http://www.flickr.com/photos/bogdansuditu

http://www.flickr.com/photos/77096872@N00/2547160291/http://www.flickr.com/photos/edvvc/1972546648/http://www.flickr.com/photos/amagill/34762677/

http://www.flickr.com/photos/celinesphotographer/360918623/

Wednesday, May 6, 2009

Thanks

Heidi VegaRails team

Yehuda KatzCarl Lerche

Laurent SansonettiRich Kilmer

Ninh Hernandez BuiHongli not-so-MacLovin’ Lai

Dan Kubb

Wednesday, May 6, 2009