SlideShare uma empresa Scribd logo
1 de 57
Baixar para ler offline
The Rails Way
Approach to modern web applications with
               Rails 3.2
The Performance Golden Rule
80% of end-users response time is
downloading all the assets.
The Rails Way to managing
assets:
    HTTP Streaming
   The Assets Pipeline
Assets Pipeline



● Assets concatenation
● Assets minification
● Support for high-level languages
  ○ CoffeeScript
  ○ SASS
● Assets fingerprinting
Syntactically Awesome Stylesheets
$blue: #3bbfce;
$margin: 16px;

.content-navigation {
  border-color: $blue;
  color:
    darken($blue, 9%);
}

.border {
  padding: $margin / 2;
  margin: $margin / 2;
  border-color: $blue;
}
CoffeeScript
class ProfileCompetences extends Backbone.View
  tagName: 'ul'
  className: 'inputs-select'

 initialize: ->
   @collection.on('reset', @render, this)

 render: ->
   competences = @collection.competences()

   _.each competences, (competence) =>
     view = new AutosaveSelectOption(model: @model, dict: competence)
     $(@el).append(view.render().el)

    this
Serving Static Assets




 Rails by default doesn't serve static assets in
           production environment.
Deployment
ict-ref-cloud/
     current -> ~/ict-ref-cloud/releases/20120904134910
     releases/
          20120904134910/
               app/
               config/
                    database.yml -> ~/ict-ref-cloud/shared/config/database.yml
               public/
                    assets -> ~/ict-ref-cloud/shared/assets
     shared/
          assets/
               application-8e3bd046319a574dc48990673b1a4dd9.js
               application-8e3bd046319a574dc48990673b1a4dd9.js.gz
               application.css
               application.css.gz
          config/
               database.yml
Deployment

                        nginx     ~/ict-ref-cloud/current/public




/tmp/unicorn.ict-ref-cloud.sock




                       unicorn    ~/ict-ref-cloud/current
OWASP Top Ten Security Risk
 1.   Injection
 2.   Cross Site Scripting
 3.   Broken Authentication and Session Management
 4.   Insecure Direct Object Reference
 5.   Cross Site Request Forgery
 6.   Security Misconfiguration
 7.   Insecure Cryptographic Storage
 8.   Failure To Restrict URL Access
 9.   Insufficient Transport Layer Protection
10.   Unvalidated Redirects and Forwards
OWASP Top Ten Security Risk
 1.   Injection
 2.   Cross Site Scripting
 3.   Broken Authentication and Session Management
 4.   Insecure Direct Object Reference
 5.   Cross Site Request Forgery
 6.   Security Misconfiguration
 7.   Insecure Cryptographic Storage
 8.   Failure To Restrict URL Access
 9.   Insufficient Transport Layer Protection
10.   Unvalidated Redirects and Forwards


 Problems related specifically to view layer.
The Rails Way to security:
     CSRF protection
     XSS protection
Cross Site Request Forgery
/app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  protect_from_forgery
end

/app/views/layouts/application.html.erb
<head>
    <%= csrf_meta_tags %>
</head>



<meta content="authenticity_token" name="csrf-param">
<meta content="KklMulGyhEfVztqfpMn5nRYc7zv+tNYb3YovBwOhTic="
    name="csrf-token">
Cross Site Scripting

<div id="comments">
    <% @post.comments.each do |comment| %>
        <div class="comment">
            <h4><%= comment.author %> say's:</h4>
            <p><%= comment.content %></p>
        </div>
    <% end %>
</div>



<%# Insecure! %>
<%= raw product.description %>
The Rails Way to routing:
  Non-Resourceful routes
    Resourceful routes
   SEO friendly URL's
Non-Resourceful Routes
match 'products/:id' => 'products#show'
GET /products/10

post 'products' => 'products#create'
POST /products

namespace :api do
   put 'products/:id' => 'api/products#update'
end
PUT /api/products/10
Non-Resourceful Routes

match 'photos/show' => 'photos#show', :via => [:get, :post]

match 'photos/:id' => 'photos#show', :constraints => { :id => /
[A-Z]d{5}/ }

match "photos", :constraints => { :subdomain => "admin" }

match "/stories/:name" => redirect("/posts/%{name}")

match 'books/*section/:title' => 'books#show'

root :to => 'pages#main'
Resourceful Routes

resources :photos

get '/photos' => 'photos#index'
get '/photos/new' => 'photos#new'
post '/photos' => 'photos#create'
get '/photos/:id' => 'photos#show'
get '/photos/:id/edit' => 'photos#edit'
put '/photos/:id' => 'photo#update'
delete '/photos/:id' => 'photo#destroy'
Resourceful Routes


resource :profile

get '/profile/new' => 'profiles#new'
post '/profile' => 'profiles#create'
get '/profile' => 'profiles#show'
get '/profile/edit' => 'profiles#edit'
put '/profile' => 'profile#update'
delete '/profile' => 'profile#destroy'
Named Routes



<%= link_to 'Profile', profile_path %>
=> <a href="/profile">Profile</a>

<%= link_to 'Preview', @photo %>
=> <a href="/photo/10">Preview</a>
SEO Friendy URL's
                                                                 <%= link_to product.name, product %>


                                                                       Will generate

                                                                 /products/14-foo-bar
  /products/14-foo-bar                                           "/products/:id" => "products#show"
                                                                 { :id => "14-foo-bar" }
  class Product < ActiveRecord::Base
    def to_param
      "#{id}-#{name.parametrize}"
    end                                                          Product.find(params[:id])

  end
                                                                       Will call to_i
                                                                 Product.find(14)




Example from: http://www.codeschool.com/courses/rails-best-practices
The Rails Way to view
rendering:
   Response rendering
   Structuring Layouts
          AJAX
Response Rendering


/app
                                 /app
    /controllers
                                     /views
        products_controller.rb
                                         /products
        users_controller.rb
                                             index.html.erb
                                             show.html.erb
                                         /users
                                             index.html.erb
                                             new.html.erb
Response Rendering
class UsersController < ApplicationController
    def new
        @user = User.new                        new.html.erb
    end

      def create
          @user = User.new(params[:user])
          if @user.save
              redirect_to :action => :show      show.html.erb
          else
              render :new                       new.html.erb
          end
      end
end
Rendering Response


render   :edit
render   :action => :edit
render   'edit'
render   'edit.html.erb'

render :template => 'products/edit'
render 'products/edit'

render :file => '/path/to/file'
render '/path/to/file'
Rendering Response

render :inline => '<p><%= @comment.content %></p>'

render :text => 'OK'

render :json => @product
render :xml => @product

render :js => "alert('Hello Rails');"

render :status => 500
render :status => :forbidden

render :nothing => true, :status => :created
Content Negotiation



respond_to do |format|
   format.html
   format.json { render :json => @product }
   format.js
end
Content Negotiation

class ProductsController < ApplicationController
    respond_to :html, :json, :js

      def edit
        respond_with Product.find(params[:id])
      end

      def update
        respond_with Product.update(params[:id], params[:product])
      end
end
Structuring Layout


/app
   /views
      /layouts
         application.html.erb (default)
         users.html.erb (UsersController)
         public.html.erb (layout 'public')
Structuring Layout

<!DOCTYPE html>
<head>
   <title>User <%= yield :title %></title>
</head>
<html>
   <body>
      <%= yield %>
   </body>
</html>
Structuring Layout



<% content_for :title, @post.title %>

<div id="post">
   <h2><%= @post.title %></h2>
   <div><%= @post.content %></div>
</div>
View Helpers



module ApplicationHelper
   def title(title)
      content_for :title, title
   end
end
View Helpers



<% title @post.title %>

<div id="post">
   <h2><%= @post.title %></h2>
   <div><%= @post.content %></div>
</div>
Partials


/app
   /views
      /products
         _form.html.erb
         _product.html.erb
         index.html.erb
         edit.html.erb
         new.html.erb
Partials


/app/views/products/_product.html.erb

<div class="product">
   <h2><%= product.name %></h2>
   <p><%= product.description %></p>
</div>

                     Partial parameter
Partials



<h1>Products</h1>

<% @products.each do |product| %>
   <% render 'products/product',
      :product => product %>
<% end %>
Partials



<h1>Products</h1>

<% @products.each do |product| %>
   <% render product %>
<% end %>
Partials




<h1>Products</h1>

<% render @products %>
Partials
/app/views/products/_form.html.erb

<%= form_for @user do |f| %>
    <div class="input">
        <%= f.label :name %>
        <%= f.text_field :name %>
    </div>
    <div class="input">
        <%= f.label :description %>
        <%= f.text_area :description %>
    </div>
    <div class="actions">
        <%= f.submit %>
    </div>
<% end %>
Partials



../products/new.html.erb   ../products/edit.html.erb

<h1>New Product</h1>       <h1>Edit Product</h1>
<div id="form">            <div id="form">
   <% render 'form' %>        <% render 'form' %>
</div>                     </div>
AJAX
/app/views/products/_form.html.erb

<%= form_for @user, :remote => true do |f| %>
    <div class="input">
        <%= f.label :name %>
        <%= f.text_field :name %>
    </div>
    <div class="input">
        <%= f.label :description %>
        <%= f.text_area :description %>
    </div>
    <div class="actions">
        <%= f.submit %>
    </div>
<% end %>
AJAX
/app/controllers/products_controller.rb
class ProductsController < ApplicationController
    def create
        @product = Product.new(params[:product])
        respond_to do |format|
            if @product.save
                format.html { redirect_to @product }
            else
                format.html { render :action => 'new' }
                format.js
            end
        end
    end
end
AJAX




/app/views/products/create.js.erb

$('#form').html("<%= escape_javascript(render 'form') %>");
AJAX


/app/views/products/index.html.erb
<%= link_to "Delete", product, method: :delete, remote: true %>
<a href="/products/1" data-method="delete"
    data-remote="true" rel="nofollow">Delete</a>
        (Rails is using unobtrusive javascript technique)

/app/views/products/destroy.js.erb
$("#<%= dom_id @product %>").fadeOut();
The Rails Way to caching:
     Basic Caching
      Memoization
Page Caching

class ProductsController < ActionController
  caches_page :index

  def index
    @products = Product.all
  end

  def create
    expire_page :action => :index
  end
end

Page caching won't work with filters.
Action Caching
class ProductsController < ActionController
  before_filter :authenticate_user!
  caches_action :index

  def index
    @products = Product.all
  end

  def create
    expire_action :action => :index
  end
end
Fragment Caching
<% cache do %>
  All available products:
  <% @products.each do |p| %>
    <%= link_to p.name, product_url(p) %>
  <% end %>
<% end %>




expire_fragment(
  :controller => 'products',
  :action => 'recent',
  :action_suffix => 'all_products'
)
Sweepers

class ProductSweeper < ActionController::Caching::Sweeper
  observe Product

  def after_create(product)
    # Expire the index page now that we added a new product
    expire_page(:controller => 'products', :action => 'index')

    # Expire a fragment
    expire_fragment('all_available_products')
  end
end
Conditional GET support


class ProductsController < ApplicationController

  def show
    @product = Product.find(params[:id])

    if stale?(:last_modified => @product.updated_at.utc, :etag => @product)
      respond_to do |format|
        # ... normal response processing
      end
    end
  end
end
Memoization


class City < ActiveRecord::Base
   attr_accesible :name, :zip, :lat, :lon

   def display_name
      @display_name ||= "#@zip #@name"
   end
end
The Rails Way to solve
typical problems:
       N+1 Problem
 Fetching object in batches
N+1 Problem
class User
  def recent_followers
    self.followers.recent.collect do |f|
      f.user.name
    end
  end
end

Select followers where user_id=1
    Select user where id=2
    Select user where id=3
    Select user where id=4
    Select user where id=5

Source: http://www.codeschool.com/courses/rails-best-practices
N+1 Problem
class User
  def recent_followers
    self.followers.recent.includes(:user).collect do |f|
      f.user.name
    end
  end
end

Select followers where user_id=1
    Select users where user_id in (2,3,4,5)


Bullet Gem:
https://github.com/flyerhzm/bullet
Source: http://www.codeschool.com/courses/rails-best-practices
Fetching objects in Java


List<Tweet> tweets = tweetDao.findAllForUser(user);
for (Tweet tweet : tweets) {
    // ...
}

for (Tweet tweet : user.getTweets()) {
   // ...
}
Fetching objects in Rails

Tweet.where(user: user).find_each do |tweet|
    # ...
end

user.tweets.find_each(batch_size: 5000) do |tweet|
    # ...
end




By default pulls batches of 1,000 at a time
Try Rails!

Mais conteúdo relacionado

Mais procurados

JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011Arun Gupta
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Luka Zakrajšek
 
Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]Tri Nguyen
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsCarol McDonald
 
Workshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSWorkshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSVisual Engineering
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverSpike Brehm
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascriptaglemann
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf Conference
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJSAaronius
 
Ionic tabs template explained
Ionic tabs template explainedIonic tabs template explained
Ionic tabs template explainedRamesh BN
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todaygerbille
 
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Java Web Development with Stripes
Java Web Development with StripesJava Web Development with Stripes
Java Web Development with StripesSamuel Santos
 
Single page webapps & javascript-testing
Single page webapps & javascript-testingSingle page webapps & javascript-testing
Single page webapps & javascript-testingsmontanari
 
Ch9 .Best Practices for Class-Based Views
Ch9 .Best Practices  for  Class-Based ViewsCh9 .Best Practices  for  Class-Based Views
Ch9 .Best Practices for Class-Based ViewsWilly Liu
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkara JUG
 
Dom selecting & jQuery
Dom selecting & jQueryDom selecting & jQuery
Dom selecting & jQueryKim Hunmin
 

Mais procurados (20)

JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011JavaServer Faces 2.0 - JavaOne India 2011
JavaServer Faces 2.0 - JavaOne India 2011
 
Django Class-based views (Slovenian)
Django Class-based views (Slovenian)Django Class-based views (Slovenian)
Django Class-based views (Slovenian)
 
Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]
 
Rest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.jsRest with Java EE 6 , Security , Backbone.js
Rest with Java EE 6 , Security , Backbone.js
 
Workshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJSWorkshop 27: Isomorphic web apps with ReactJS
Workshop 27: Isomorphic web apps with ReactJS
 
Introducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and serverIntroducing Rendr: Run your Backbone.js apps on the client and server
Introducing Rendr: Run your Backbone.js apps on the client and server
 
Beyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance JavascriptBeyond DOMReady: Ultra High-Performance Javascript
Beyond DOMReady: Ultra High-Performance Javascript
 
Java Server Faces
Java Server FacesJava Server Faces
Java Server Faces
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
 
Ionic tabs template explained
Ionic tabs template explainedIonic tabs template explained
Ionic tabs template explained
 
Creating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of todayCreating the interfaces of the future with the APIs of today
Creating the interfaces of the future with the APIs of today
 
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
 
Java Web Development with Stripes
Java Web Development with StripesJava Web Development with Stripes
Java Web Development with Stripes
 
JBoss Seam vs JSF
JBoss Seam vs JSFJBoss Seam vs JSF
JBoss Seam vs JSF
 
Stripes Framework
Stripes FrameworkStripes Framework
Stripes Framework
 
Single page webapps & javascript-testing
Single page webapps & javascript-testingSingle page webapps & javascript-testing
Single page webapps & javascript-testing
 
Ch9 .Best Practices for Class-Based Views
Ch9 .Best Practices  for  Class-Based ViewsCh9 .Best Practices  for  Class-Based Views
Ch9 .Best Practices for Class-Based Views
 
AnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFacesAnkaraJUG Kasım 2012 - PrimeFaces
AnkaraJUG Kasım 2012 - PrimeFaces
 
Dom selecting & jQuery
Dom selecting & jQueryDom selecting & jQuery
Dom selecting & jQuery
 

Destaque

Ibr skuteczne zarządzanie przedsięwzięciami
Ibr skuteczne zarządzanie przedsięwzięciamiIbr skuteczne zarządzanie przedsięwzięciami
Ibr skuteczne zarządzanie przedsięwzięciamiMichał Wojewoda
 
E-Deklaracje dla SAP Business One. Zastosowania TaskCentre®.
E-Deklaracje dla SAP Business One. Zastosowania TaskCentre®.E-Deklaracje dla SAP Business One. Zastosowania TaskCentre®.
E-Deklaracje dla SAP Business One. Zastosowania TaskCentre®.Orbis Software Polska
 
[PL] Zarządzanie procesami biznesowymi z wykorzystaniem platformy SharePoint
[PL] Zarządzanie procesami biznesowymi z wykorzystaniem platformy SharePoint[PL] Zarządzanie procesami biznesowymi z wykorzystaniem platformy SharePoint
[PL] Zarządzanie procesami biznesowymi z wykorzystaniem platformy SharePointDatapolis
 
infoShare 2011 - Daniel Owsianski, Zbigniew Sobiecki - Jak robimy biznes na j...
infoShare 2011 - Daniel Owsianski, Zbigniew Sobiecki - Jak robimy biznes na j...infoShare 2011 - Daniel Owsianski, Zbigniew Sobiecki - Jak robimy biznes na j...
infoShare 2011 - Daniel Owsianski, Zbigniew Sobiecki - Jak robimy biznes na j...Infoshare
 
Wojciech Kosiński Zarzadzanie Procesami Biznesowymi Jako Kluczowa Funkcja O...
Wojciech Kosiński   Zarzadzanie Procesami Biznesowymi Jako Kluczowa Funkcja O...Wojciech Kosiński   Zarzadzanie Procesami Biznesowymi Jako Kluczowa Funkcja O...
Wojciech Kosiński Zarzadzanie Procesami Biznesowymi Jako Kluczowa Funkcja O...nexik
 
Wydajnosc+Organizacji+Pracy+ +Dariusz+Lipski
Wydajnosc+Organizacji+Pracy+ +Dariusz+LipskiWydajnosc+Organizacji+Pracy+ +Dariusz+Lipski
Wydajnosc+Organizacji+Pracy+ +Dariusz+Lipskidareklipski
 
Metodologia projektowa
Metodologia projektowaMetodologia projektowa
Metodologia projektowaUM Łódzkie
 
Plan marketingowy Betterware
Plan marketingowy BetterwarePlan marketingowy Betterware
Plan marketingowy Betterwaremsuwara
 
Projekt
ProjektProjekt
ProjektTeresa
 
Prezentacja konferencja
Prezentacja konferencjaPrezentacja konferencja
Prezentacja konferencjaUM Łódzkie
 
Budowanie przewagi konkurencyjnej BPM
Budowanie przewagi konkurencyjnej BPMBudowanie przewagi konkurencyjnej BPM
Budowanie przewagi konkurencyjnej BPMAlicja Sieminska
 
Modele biznesowe i sformalizowane metody ich dokumentowania
Modele biznesowe i sformalizowane metody ich dokumentowaniaModele biznesowe i sformalizowane metody ich dokumentowania
Modele biznesowe i sformalizowane metody ich dokumentowaniaJaroslaw Zelinski
 
Jak zrealizować projekt na czas? Metoda łańcucha krytycznego w zarządzaniu pr...
Jak zrealizować projekt na czas? Metoda łańcucha krytycznego w zarządzaniu pr...Jak zrealizować projekt na czas? Metoda łańcucha krytycznego w zarządzaniu pr...
Jak zrealizować projekt na czas? Metoda łańcucha krytycznego w zarządzaniu pr...MANDARINE Project Partners
 
Model operacyjny - zobaczyć i dotknąć
Model operacyjny - zobaczyć i dotknąćModel operacyjny - zobaczyć i dotknąć
Model operacyjny - zobaczyć i dotknąćBogdan Gluszkowski
 

Destaque (20)

PRINCE2 - Start Up
PRINCE2 - Start UpPRINCE2 - Start Up
PRINCE2 - Start Up
 
Ibr skuteczne zarządzanie przedsięwzięciami
Ibr skuteczne zarządzanie przedsięwzięciamiIbr skuteczne zarządzanie przedsięwzięciami
Ibr skuteczne zarządzanie przedsięwzięciami
 
E-Deklaracje dla SAP Business One. Zastosowania TaskCentre®.
E-Deklaracje dla SAP Business One. Zastosowania TaskCentre®.E-Deklaracje dla SAP Business One. Zastosowania TaskCentre®.
E-Deklaracje dla SAP Business One. Zastosowania TaskCentre®.
 
Marek Kowalczyk na TEDxSabreKrakow 2015-03-24
Marek Kowalczyk na TEDxSabreKrakow 2015-03-24Marek Kowalczyk na TEDxSabreKrakow 2015-03-24
Marek Kowalczyk na TEDxSabreKrakow 2015-03-24
 
Trzy scenariusze dla bibliotek - Alek Tarkowski
Trzy scenariusze dla bibliotek - Alek TarkowskiTrzy scenariusze dla bibliotek - Alek Tarkowski
Trzy scenariusze dla bibliotek - Alek Tarkowski
 
[PL] Zarządzanie procesami biznesowymi z wykorzystaniem platformy SharePoint
[PL] Zarządzanie procesami biznesowymi z wykorzystaniem platformy SharePoint[PL] Zarządzanie procesami biznesowymi z wykorzystaniem platformy SharePoint
[PL] Zarządzanie procesami biznesowymi z wykorzystaniem platformy SharePoint
 
infoShare 2011 - Daniel Owsianski, Zbigniew Sobiecki - Jak robimy biznes na j...
infoShare 2011 - Daniel Owsianski, Zbigniew Sobiecki - Jak robimy biznes na j...infoShare 2011 - Daniel Owsianski, Zbigniew Sobiecki - Jak robimy biznes na j...
infoShare 2011 - Daniel Owsianski, Zbigniew Sobiecki - Jak robimy biznes na j...
 
Wojciech Kosiński Zarzadzanie Procesami Biznesowymi Jako Kluczowa Funkcja O...
Wojciech Kosiński   Zarzadzanie Procesami Biznesowymi Jako Kluczowa Funkcja O...Wojciech Kosiński   Zarzadzanie Procesami Biznesowymi Jako Kluczowa Funkcja O...
Wojciech Kosiński Zarzadzanie Procesami Biznesowymi Jako Kluczowa Funkcja O...
 
Wydajnosc+Organizacji+Pracy+ +Dariusz+Lipski
Wydajnosc+Organizacji+Pracy+ +Dariusz+LipskiWydajnosc+Organizacji+Pracy+ +Dariusz+Lipski
Wydajnosc+Organizacji+Pracy+ +Dariusz+Lipski
 
Metodologia projektowa
Metodologia projektowaMetodologia projektowa
Metodologia projektowa
 
Projekt bajer
Projekt bajerProjekt bajer
Projekt bajer
 
Plan marketingowy Betterware
Plan marketingowy BetterwarePlan marketingowy Betterware
Plan marketingowy Betterware
 
Projekt
ProjektProjekt
Projekt
 
KBO 2017 projekty małe
KBO 2017 projekty małeKBO 2017 projekty małe
KBO 2017 projekty małe
 
Prezentacja konferencja
Prezentacja konferencjaPrezentacja konferencja
Prezentacja konferencja
 
Budowanie przewagi konkurencyjnej BPM
Budowanie przewagi konkurencyjnej BPMBudowanie przewagi konkurencyjnej BPM
Budowanie przewagi konkurencyjnej BPM
 
Projekty na czas
Projekty na czasProjekty na czas
Projekty na czas
 
Modele biznesowe i sformalizowane metody ich dokumentowania
Modele biznesowe i sformalizowane metody ich dokumentowaniaModele biznesowe i sformalizowane metody ich dokumentowania
Modele biznesowe i sformalizowane metody ich dokumentowania
 
Jak zrealizować projekt na czas? Metoda łańcucha krytycznego w zarządzaniu pr...
Jak zrealizować projekt na czas? Metoda łańcucha krytycznego w zarządzaniu pr...Jak zrealizować projekt na czas? Metoda łańcucha krytycznego w zarządzaniu pr...
Jak zrealizować projekt na czas? Metoda łańcucha krytycznego w zarządzaniu pr...
 
Model operacyjny - zobaczyć i dotknąć
Model operacyjny - zobaczyć i dotknąćModel operacyjny - zobaczyć i dotknąć
Model operacyjny - zobaczyć i dotknąć
 

Semelhante a The Rails Way to Modern Web Apps

Resource and view
Resource and viewResource and view
Resource and viewPapp Laszlo
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsMark
 
Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2A.K.M. Ahsrafuzzaman
 
Angular.js Fundamentals
Angular.js FundamentalsAngular.js Fundamentals
Angular.js FundamentalsMark
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful RailsViget Labs
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful RailsBen Scofield
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30fiyuer
 
Ruby on Rails : RESTful 和 Ajax
Ruby on Rails : RESTful 和 AjaxRuby on Rails : RESTful 和 Ajax
Ruby on Rails : RESTful 和 AjaxWen-Tien Chang
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalystsvilen.ivanov
 
Ruby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapRuby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapMarcio Marinho
 
What's new in Rails 4
What's new in Rails 4What's new in Rails 4
What's new in Rails 4Fabio Akita
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in RailsSeungkyun Nam
 
WebcampZG - Rails 4
WebcampZG - Rails 4WebcampZG - Rails 4
WebcampZG - Rails 4shnikola
 
Intro to-rails-webperf
Intro to-rails-webperfIntro to-rails-webperf
Intro to-rails-webperfNew Relic
 
Patterns Are Good For Managers
Patterns Are Good For ManagersPatterns Are Good For Managers
Patterns Are Good For ManagersAgileThought
 

Semelhante a The Rails Way to Modern Web Apps (20)

Resource and view
Resource and viewResource and view
Resource and view
 
AngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.jsAngularJS vs. Ember.js vs. Backbone.js
AngularJS vs. Ember.js vs. Backbone.js
 
Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2
 
JS-05-Handlebars.ppt
JS-05-Handlebars.pptJS-05-Handlebars.ppt
JS-05-Handlebars.ppt
 
Angular.js Fundamentals
Angular.js FundamentalsAngular.js Fundamentals
Angular.js Fundamentals
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30
 
Django Vs Rails
Django Vs RailsDjango Vs Rails
Django Vs Rails
 
Ruby on Rails : RESTful 和 Ajax
Ruby on Rails : RESTful 和 AjaxRuby on Rails : RESTful 和 Ajax
Ruby on Rails : RESTful 和 Ajax
 
Yii Introduction
Yii IntroductionYii Introduction
Yii Introduction
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
 
Ruby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapRuby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter Bootstrap
 
What's new in Rails 4
What's new in Rails 4What's new in Rails 4
What's new in Rails 4
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in Rails
 
WebcampZG - Rails 4
WebcampZG - Rails 4WebcampZG - Rails 4
WebcampZG - Rails 4
 
Intro to-rails-webperf
Intro to-rails-webperfIntro to-rails-webperf
Intro to-rails-webperf
 
Patterns Are Good For Managers
Patterns Are Good For ManagersPatterns Are Good For Managers
Patterns Are Good For Managers
 

Mais de Michał Orman

PRINCE2 - Managing a Stage Boundary
PRINCE2 - Managing a Stage BoundaryPRINCE2 - Managing a Stage Boundary
PRINCE2 - Managing a Stage BoundaryMichał Orman
 
Prince2 Controlling a Stage
Prince2 Controlling a StagePrince2 Controlling a Stage
Prince2 Controlling a StageMichał Orman
 
PRINCE2 - Closing a Project
PRINCE2 - Closing a ProjectPRINCE2 - Closing a Project
PRINCE2 - Closing a ProjectMichał Orman
 
PRINCE2 - Managing Product Delivery
PRINCE2 - Managing Product DeliveryPRINCE2 - Managing Product Delivery
PRINCE2 - Managing Product DeliveryMichał Orman
 
PRINCE2 - Project Initiation
PRINCE2 - Project InitiationPRINCE2 - Project Initiation
PRINCE2 - Project InitiationMichał Orman
 
PRINCE2 - Directing a Project
PRINCE2 - Directing a ProjectPRINCE2 - Directing a Project
PRINCE2 - Directing a ProjectMichał Orman
 
Seam framework in_action
Seam framework in_actionSeam framework in_action
Seam framework in_actionMichał Orman
 

Mais de Michał Orman (7)

PRINCE2 - Managing a Stage Boundary
PRINCE2 - Managing a Stage BoundaryPRINCE2 - Managing a Stage Boundary
PRINCE2 - Managing a Stage Boundary
 
Prince2 Controlling a Stage
Prince2 Controlling a StagePrince2 Controlling a Stage
Prince2 Controlling a Stage
 
PRINCE2 - Closing a Project
PRINCE2 - Closing a ProjectPRINCE2 - Closing a Project
PRINCE2 - Closing a Project
 
PRINCE2 - Managing Product Delivery
PRINCE2 - Managing Product DeliveryPRINCE2 - Managing Product Delivery
PRINCE2 - Managing Product Delivery
 
PRINCE2 - Project Initiation
PRINCE2 - Project InitiationPRINCE2 - Project Initiation
PRINCE2 - Project Initiation
 
PRINCE2 - Directing a Project
PRINCE2 - Directing a ProjectPRINCE2 - Directing a Project
PRINCE2 - Directing a Project
 
Seam framework in_action
Seam framework in_actionSeam framework in_action
Seam framework in_action
 

Último

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 

Último (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 

The Rails Way to Modern Web Apps

  • 1. The Rails Way Approach to modern web applications with Rails 3.2
  • 2. The Performance Golden Rule 80% of end-users response time is downloading all the assets.
  • 3. The Rails Way to managing assets: HTTP Streaming The Assets Pipeline
  • 4. Assets Pipeline ● Assets concatenation ● Assets minification ● Support for high-level languages ○ CoffeeScript ○ SASS ● Assets fingerprinting
  • 5. Syntactically Awesome Stylesheets $blue: #3bbfce; $margin: 16px; .content-navigation { border-color: $blue; color: darken($blue, 9%); } .border { padding: $margin / 2; margin: $margin / 2; border-color: $blue; }
  • 6. CoffeeScript class ProfileCompetences extends Backbone.View tagName: 'ul' className: 'inputs-select' initialize: -> @collection.on('reset', @render, this) render: -> competences = @collection.competences() _.each competences, (competence) => view = new AutosaveSelectOption(model: @model, dict: competence) $(@el).append(view.render().el) this
  • 7. Serving Static Assets Rails by default doesn't serve static assets in production environment.
  • 8. Deployment ict-ref-cloud/ current -> ~/ict-ref-cloud/releases/20120904134910 releases/ 20120904134910/ app/ config/ database.yml -> ~/ict-ref-cloud/shared/config/database.yml public/ assets -> ~/ict-ref-cloud/shared/assets shared/ assets/ application-8e3bd046319a574dc48990673b1a4dd9.js application-8e3bd046319a574dc48990673b1a4dd9.js.gz application.css application.css.gz config/ database.yml
  • 9. Deployment nginx ~/ict-ref-cloud/current/public /tmp/unicorn.ict-ref-cloud.sock unicorn ~/ict-ref-cloud/current
  • 10. OWASP Top Ten Security Risk 1. Injection 2. Cross Site Scripting 3. Broken Authentication and Session Management 4. Insecure Direct Object Reference 5. Cross Site Request Forgery 6. Security Misconfiguration 7. Insecure Cryptographic Storage 8. Failure To Restrict URL Access 9. Insufficient Transport Layer Protection 10. Unvalidated Redirects and Forwards
  • 11. OWASP Top Ten Security Risk 1. Injection 2. Cross Site Scripting 3. Broken Authentication and Session Management 4. Insecure Direct Object Reference 5. Cross Site Request Forgery 6. Security Misconfiguration 7. Insecure Cryptographic Storage 8. Failure To Restrict URL Access 9. Insufficient Transport Layer Protection 10. Unvalidated Redirects and Forwards Problems related specifically to view layer.
  • 12. The Rails Way to security: CSRF protection XSS protection
  • 13. Cross Site Request Forgery /app/controllers/application_controller.rb class ApplicationController < ActionController::Base protect_from_forgery end /app/views/layouts/application.html.erb <head> <%= csrf_meta_tags %> </head> <meta content="authenticity_token" name="csrf-param"> <meta content="KklMulGyhEfVztqfpMn5nRYc7zv+tNYb3YovBwOhTic=" name="csrf-token">
  • 14. Cross Site Scripting <div id="comments"> <% @post.comments.each do |comment| %> <div class="comment"> <h4><%= comment.author %> say's:</h4> <p><%= comment.content %></p> </div> <% end %> </div> <%# Insecure! %> <%= raw product.description %>
  • 15. The Rails Way to routing: Non-Resourceful routes Resourceful routes SEO friendly URL's
  • 16. Non-Resourceful Routes match 'products/:id' => 'products#show' GET /products/10 post 'products' => 'products#create' POST /products namespace :api do put 'products/:id' => 'api/products#update' end PUT /api/products/10
  • 17. Non-Resourceful Routes match 'photos/show' => 'photos#show', :via => [:get, :post] match 'photos/:id' => 'photos#show', :constraints => { :id => / [A-Z]d{5}/ } match "photos", :constraints => { :subdomain => "admin" } match "/stories/:name" => redirect("/posts/%{name}") match 'books/*section/:title' => 'books#show' root :to => 'pages#main'
  • 18. Resourceful Routes resources :photos get '/photos' => 'photos#index' get '/photos/new' => 'photos#new' post '/photos' => 'photos#create' get '/photos/:id' => 'photos#show' get '/photos/:id/edit' => 'photos#edit' put '/photos/:id' => 'photo#update' delete '/photos/:id' => 'photo#destroy'
  • 19. Resourceful Routes resource :profile get '/profile/new' => 'profiles#new' post '/profile' => 'profiles#create' get '/profile' => 'profiles#show' get '/profile/edit' => 'profiles#edit' put '/profile' => 'profile#update' delete '/profile' => 'profile#destroy'
  • 20. Named Routes <%= link_to 'Profile', profile_path %> => <a href="/profile">Profile</a> <%= link_to 'Preview', @photo %> => <a href="/photo/10">Preview</a>
  • 21. SEO Friendy URL's <%= link_to product.name, product %> Will generate /products/14-foo-bar /products/14-foo-bar "/products/:id" => "products#show" { :id => "14-foo-bar" } class Product < ActiveRecord::Base def to_param "#{id}-#{name.parametrize}" end Product.find(params[:id]) end Will call to_i Product.find(14) Example from: http://www.codeschool.com/courses/rails-best-practices
  • 22. The Rails Way to view rendering: Response rendering Structuring Layouts AJAX
  • 23. Response Rendering /app /app /controllers /views products_controller.rb /products users_controller.rb index.html.erb show.html.erb /users index.html.erb new.html.erb
  • 24. Response Rendering class UsersController < ApplicationController def new @user = User.new new.html.erb end def create @user = User.new(params[:user]) if @user.save redirect_to :action => :show show.html.erb else render :new new.html.erb end end end
  • 25. Rendering Response render :edit render :action => :edit render 'edit' render 'edit.html.erb' render :template => 'products/edit' render 'products/edit' render :file => '/path/to/file' render '/path/to/file'
  • 26. Rendering Response render :inline => '<p><%= @comment.content %></p>' render :text => 'OK' render :json => @product render :xml => @product render :js => "alert('Hello Rails');" render :status => 500 render :status => :forbidden render :nothing => true, :status => :created
  • 27. Content Negotiation respond_to do |format| format.html format.json { render :json => @product } format.js end
  • 28. Content Negotiation class ProductsController < ApplicationController respond_to :html, :json, :js def edit respond_with Product.find(params[:id]) end def update respond_with Product.update(params[:id], params[:product]) end end
  • 29. Structuring Layout /app /views /layouts application.html.erb (default) users.html.erb (UsersController) public.html.erb (layout 'public')
  • 30. Structuring Layout <!DOCTYPE html> <head> <title>User <%= yield :title %></title> </head> <html> <body> <%= yield %> </body> </html>
  • 31. Structuring Layout <% content_for :title, @post.title %> <div id="post"> <h2><%= @post.title %></h2> <div><%= @post.content %></div> </div>
  • 32. View Helpers module ApplicationHelper def title(title) content_for :title, title end end
  • 33. View Helpers <% title @post.title %> <div id="post"> <h2><%= @post.title %></h2> <div><%= @post.content %></div> </div>
  • 34. Partials /app /views /products _form.html.erb _product.html.erb index.html.erb edit.html.erb new.html.erb
  • 35. Partials /app/views/products/_product.html.erb <div class="product"> <h2><%= product.name %></h2> <p><%= product.description %></p> </div> Partial parameter
  • 36. Partials <h1>Products</h1> <% @products.each do |product| %> <% render 'products/product', :product => product %> <% end %>
  • 37. Partials <h1>Products</h1> <% @products.each do |product| %> <% render product %> <% end %>
  • 39. Partials /app/views/products/_form.html.erb <%= form_for @user do |f| %> <div class="input"> <%= f.label :name %> <%= f.text_field :name %> </div> <div class="input"> <%= f.label :description %> <%= f.text_area :description %> </div> <div class="actions"> <%= f.submit %> </div> <% end %>
  • 40. Partials ../products/new.html.erb ../products/edit.html.erb <h1>New Product</h1> <h1>Edit Product</h1> <div id="form"> <div id="form"> <% render 'form' %> <% render 'form' %> </div> </div>
  • 41. AJAX /app/views/products/_form.html.erb <%= form_for @user, :remote => true do |f| %> <div class="input"> <%= f.label :name %> <%= f.text_field :name %> </div> <div class="input"> <%= f.label :description %> <%= f.text_area :description %> </div> <div class="actions"> <%= f.submit %> </div> <% end %>
  • 42. AJAX /app/controllers/products_controller.rb class ProductsController < ApplicationController def create @product = Product.new(params[:product]) respond_to do |format| if @product.save format.html { redirect_to @product } else format.html { render :action => 'new' } format.js end end end end
  • 44. AJAX /app/views/products/index.html.erb <%= link_to "Delete", product, method: :delete, remote: true %> <a href="/products/1" data-method="delete" data-remote="true" rel="nofollow">Delete</a> (Rails is using unobtrusive javascript technique) /app/views/products/destroy.js.erb $("#<%= dom_id @product %>").fadeOut();
  • 45. The Rails Way to caching: Basic Caching Memoization
  • 46. Page Caching class ProductsController < ActionController caches_page :index def index @products = Product.all end def create expire_page :action => :index end end Page caching won't work with filters.
  • 47. Action Caching class ProductsController < ActionController before_filter :authenticate_user! caches_action :index def index @products = Product.all end def create expire_action :action => :index end end
  • 48. Fragment Caching <% cache do %> All available products: <% @products.each do |p| %> <%= link_to p.name, product_url(p) %> <% end %> <% end %> expire_fragment( :controller => 'products', :action => 'recent', :action_suffix => 'all_products' )
  • 49. Sweepers class ProductSweeper < ActionController::Caching::Sweeper observe Product def after_create(product) # Expire the index page now that we added a new product expire_page(:controller => 'products', :action => 'index') # Expire a fragment expire_fragment('all_available_products') end end
  • 50. Conditional GET support class ProductsController < ApplicationController def show @product = Product.find(params[:id]) if stale?(:last_modified => @product.updated_at.utc, :etag => @product) respond_to do |format| # ... normal response processing end end end end
  • 51. Memoization class City < ActiveRecord::Base attr_accesible :name, :zip, :lat, :lon def display_name @display_name ||= "#@zip #@name" end end
  • 52. The Rails Way to solve typical problems: N+1 Problem Fetching object in batches
  • 53. N+1 Problem class User def recent_followers self.followers.recent.collect do |f| f.user.name end end end Select followers where user_id=1 Select user where id=2 Select user where id=3 Select user where id=4 Select user where id=5 Source: http://www.codeschool.com/courses/rails-best-practices
  • 54. N+1 Problem class User def recent_followers self.followers.recent.includes(:user).collect do |f| f.user.name end end end Select followers where user_id=1 Select users where user_id in (2,3,4,5) Bullet Gem: https://github.com/flyerhzm/bullet Source: http://www.codeschool.com/courses/rails-best-practices
  • 55. Fetching objects in Java List<Tweet> tweets = tweetDao.findAllForUser(user); for (Tweet tweet : tweets) { // ... } for (Tweet tweet : user.getTweets()) { // ... }
  • 56. Fetching objects in Rails Tweet.where(user: user).find_each do |tweet| # ... end user.tweets.find_each(batch_size: 5000) do |tweet| # ... end By default pulls batches of 1,000 at a time