5
play

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


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

  2. 5 2004 - 2009

  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

  4. We’re still here

  5. The philosophy of Rails 3

  6. The progress of Rails 3

  7. New router Faster Route by subdomains, user agents, more Route to other Rack machinery

  8. 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

  9. 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

  10. XSS protection

  11. <%# => "I've hacked you good! <script>" %> <%= comment.body %> <%# => "I've hacked you bad! &lt;script&gt;" %> <%=h comment.body %> <%# => "I've hacked you good! &lt;script&gt;" %> <%= comment.body %> <%# => "I've hacked you bad! <script>" %> <%=raw comment.body %>

  12. 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

  13. JavaScript goes unobtrusive & agnostic

  14. <%= 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>

  15. <% 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">

  16. <%= 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>

  17. <%= 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>

  18. $(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(); } });

  19. More agnosticism Action ORM Generators

  20. The great refactoring Abstract Controller + Action Dispatch Action Relation underpins Active Record Cherry picking from Active Support Speedy callbacks

  21. The real secret to high productivity

  22. Renegotiate requirements

  23. “Sure, whatever” Stakeholders every where

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

  25. Programmer

  26. Partner

  27. Questions?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend