rails 3 and the real secret to high productivity presentation

41
Rails 3 ..and the real secret to high productivity

Upload: techdude

Post on 05-Dec-2014

2.715 views

Category:

Technology


0 download

DESCRIPTION

DHH presentation from RailsConf09

TRANSCRIPT

Page 1: Rails 3 And The Real Secret To High Productivity Presentation

Rails 3 ..and the real secret to high productivity

Page 2: Rails 3 And The Real Secret To High Productivity Presentation

52004 - 2009

Page 3: Rails 3 And The Real Secret To High Productivity Presentation

"You may have noticed that pretty much everyone in

the Ruby camp are insultants with many of them being

book authors attempting to capitalize on hype." James McGovern

Page 4: Rails 3 And The Real Secret To High Productivity Presentation
Page 5: Rails 3 And The Real Secret To High Productivity Presentation
Page 6: Rails 3 And The Real Secret To High Productivity Presentation
Page 7: Rails 3 And The Real Secret To High Productivity Presentation
Page 8: Rails 3 And The Real Secret To High Productivity Presentation

We’re still here

Page 9: Rails 3 And The Real Secret To High Productivity Presentation

The philosophy of Rails 3

Page 10: Rails 3 And The Real Secret To High Productivity Presentation
Page 11: Rails 3 And The Real Secret To High Productivity Presentation
Page 12: Rails 3 And The Real Secret To High Productivity Presentation
Page 13: Rails 3 And The Real Secret To High Productivity Presentation

The progress of Rails 3

Page 14: Rails 3 And The Real Secret To High Productivity Presentation

New routerFaster

Route by subdomains, user agents, more

Route to other Rack machinery

Page 15: Rails 3 And The Real Secret To High Productivity Presentation

map.with_options(:controller => "sessions") do |sessions| sessions.login "login", :action => "new", :conditions => { :method => :get } sessions.connect "login", :action => "create", :conditions => { :method => :post } sessions.logout "logout", :action => "destroy", :conditions => { :method => :post }end

controller :sessions do match 'logout', :via => :delete, :to => :destroy, :as => :logout match 'login' do get :new, :as => :login post :create endend

Page 16: Rails 3 And The Real Secret To High Productivity Presentation

map.resources :projects, :controller => 'project' do |projects| projects.resources :attachments projects.resources :participants, :collection => { :update_all => :put } projects.resources :companies, :has_many => :people, :has_one => :avatarend

resources :projects, :controller => :project do resources :attachments resources :participants do put :update_all, :on => :collection end resources :companies do resources :people resource :avatar endend

Page 17: Rails 3 And The Real Secret To High Productivity Presentation

XSS protection

Page 18: Rails 3 And The Real Secret To High Productivity Presentation

<%= comment.body %>

<%=h comment.body %>

<%# => "I've hacked you good! <script>" %>

<%# => "I've hacked you bad! &lt;script&gt;" %>

<%= comment.body %>

<%=raw comment.body %>

<%# => "I've hacked you good! &lt;script&gt;" %>

<%# => "I've hacked you bad! <script>" %>

Page 19: Rails 3 And The Real Secret To High Productivity Presentation

def safe_helper(text) content_tag(:div, text) + tag(:br)end

def needs_to_be_marked_safe_helper(text) (content_tag(:div, text) + "<br/>").html_safe!end

Page 20: Rails 3 And The Real Secret To High Productivity Presentation

JavaScript goes

unobtrusive & agnostic

Page 21: Rails 3 And The Real Secret To High Productivity Presentation

<%= link_to_remote "Delete", :url => @comment, :method => :delete %>

<a href="#" onclick="new Ajax.Request('/comments/1', {asynchronous:true, evalScripts:true, method:'delete'}); return false;">Destroy</a>

<%= link_to "Delete", @comment, :remote => true, :method => :delete %>

<a href="/comments/1" data-remote="true" data-method="delete">Destroy</a>

Page 22: Rails 3 And The Real Secret To High Productivity Presentation

<% remote_form_for(@comment) do %>

<form action="/comments" class="new_comment" id="new_comment" method="post" onsubmit="new Ajax.Request('/comments', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">

<% form_for(@comment, :remote => true) do %>

<form action="/comments" class="new_comment" id="new_comment" method="post" data-remote="true">

Page 23: Rails 3 And The Real Secret To High Productivity Presentation

<%= link_to "Delete", @comment, :method => :delete %>

<a href="/comments/1" onclick="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;">Destroy</a>

<a href="/comments/1" data-method="delete">Destroy</a>

Page 24: Rails 3 And The Real Secret To High Productivity Presentation

<%= link_to "Delete", @comment, :method => :delete, :confirm => "Are you sure?" %>

<a href="/comments/1" 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;">Destroy</a>

<a href="/comments/1" data-method="delete" data-confirm="Are you sure?">Destroy</a>

Page 25: Rails 3 And The Real Secret To High Productivity Presentation

$(document.body).observe("click", function(event) { var element = event.findElement("a['data-remote']"); if (element) { var method = element.readAttribute("data-method") || "get"; new Ajax.Request(element.readAttribute("href"), { method: method }); event.stop(); }});

Page 26: Rails 3 And The Real Secret To High Productivity Presentation

More agnosticismAction ORM

Generators

Page 27: Rails 3 And The Real Secret To High Productivity Presentation

The great refactoringAbstract Controller + Action Dispatch

Action Relation underpins Active Record

Cherry picking from Active Support

Speedy callbacks

Page 28: Rails 3 And The Real Secret To High Productivity Presentation

The real secret to high productivity

Page 29: Rails 3 And The Real Secret To High Productivity Presentation

Renegotiate requirements

Page 30: Rails 3 And The Real Secret To High Productivity Presentation
Page 31: Rails 3 And The Real Secret To High Productivity Presentation
Page 32: Rails 3 And The Real Secret To High Productivity Presentation
Page 33: Rails 3 And The Real Secret To High Productivity Presentation
Page 34: Rails 3 And The Real Secret To High Productivity Presentation
Page 35: Rails 3 And The Real Secret To High Productivity Presentation

“Sure, whatever”

Stakeholders every where

Page 36: Rails 3 And The Real Secret To High Productivity Presentation

“I don’t know how”“It’s just too hard”“I’d be bored senseless”“That would kill the abstraction”

Page 37: Rails 3 And The Real Secret To High Productivity Presentation
Page 38: Rails 3 And The Real Secret To High Productivity Presentation
Page 39: Rails 3 And The Real Secret To High Productivity Presentation

Programmer

Page 40: Rails 3 And The Real Secret To High Productivity Presentation

Partner

Page 41: Rails 3 And The Real Secret To High Productivity Presentation

Questions?