5 2004 - 2009 "You may have noticed that pretty much everyone - - PowerPoint PPT Presentation

5
SMART_READER_LITE
LIVE PREVIEW

5 2004 - 2009 "You may have noticed that pretty much everyone - - PowerPoint PPT Presentation

Rails 3 ..and the real secret to high productivity 5 2004 - 2009 "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


slide-1
SLIDE 1

Rails 3

..and the real secret to high productivity

slide-2
SLIDE 2

5

2004 - 2009

slide-3
SLIDE 3

"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
slide-4
SLIDE 4
slide-5
SLIDE 5
slide-6
SLIDE 6
slide-7
SLIDE 7
slide-8
SLIDE 8

We’re still here

slide-9
SLIDE 9

The philosophy

  • f Rails 3
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12
slide-13
SLIDE 13

The progress

  • f Rails 3
slide-14
SLIDE 14

New router

Faster Route by subdomains, user agents, more Route to other Rack machinery

slide-15
SLIDE 15 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 end end
slide-16
SLIDE 16 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 => :avatar end resources :projects, :controller => :project do resources :attachments resources :participants do put :update_all, :on => :collection end resources :companies do resources :people resource :avatar end end
slide-17
SLIDE 17

XSS protection

slide-18
SLIDE 18

<%= 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>" %>

slide-19
SLIDE 19

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

slide-20
SLIDE 20

JavaScript goes unobtrusive & agnostic

slide-21
SLIDE 21 <%= 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>
slide-22
SLIDE 22 <% 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">
slide-23
SLIDE 23 <%= 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>
slide-24
SLIDE 24 <%= 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>
slide-25
SLIDE 25 $(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(); } });
slide-26
SLIDE 26

More agnosticism

Action ORM Generators

slide-27
SLIDE 27

The great refactoring

Abstract Controller + Action Dispatch Action Relation underpins Active Record Cherry picking from Active Support Speedy callbacks

slide-28
SLIDE 28

The real secret to high productivity

slide-29
SLIDE 29

Renegotiate requirements

slide-30
SLIDE 30
slide-31
SLIDE 31
slide-32
SLIDE 32
slide-33
SLIDE 33
slide-34
SLIDE 34
slide-35
SLIDE 35

“Sure, whatever”

Stakeholders every where
slide-36
SLIDE 36

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

slide-37
SLIDE 37
slide-38
SLIDE 38
slide-39
SLIDE 39

Programmer

slide-40
SLIDE 40

Partner

slide-41
SLIDE 41

Questions?