Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

7 Gemas de Ruby on Rails que podrían salvarte el dia

1.438 visualizaciones

Publicado el

Betabeers Córdoba XIX - 05/03/2015 - 7 Gemas de Ruby on Rails que podrían salvarte el día

Publicado en: Tecnología
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Responder 
    ¿Estás seguro?    No
    Tu mensaje aparecerá aquí
  • Sé el primero en recomendar esto

7 Gemas de Ruby on Rails que podrían salvarte el dia

  1. 1. GEMAS DE RUBY ON RAILS QUE PUEDEN SALVAR TU DÍA7 Francisco Luis Aranda García @flaranda
  2. 2. Ruby on Rails
  3. 3. Ruby on Rails
  4. 4. devise #1
  5. 5. deviseplataformatec / devise Sistema de autenticación basado en Rack ! Solución ideal para MVC ! “Usa solo lo que necesites”
  6. 6. deviseplataformatec / devise 10 módulos principales Authenticable ! Omniauthable ! Confirmable ! Recoverable ! Registerable Rememberable ! Trackable ! Timeoutable ! Validatable ! Lockable
  7. 7. deviseplataformatec / devise Preparar devise en una web app gem install devise1 2 3 rails generate devise:install rails generate devise MODEL_NAME
  8. 8. deviseplataformatec / devise Prueba
  9. 9. cancancan #2
  10. 10. cancancanCanCanCommunity / cancancan Módulo de autorizaciones para Rails ! Basado en un modelo independiente “Ability” ! Integración con devise para saber quién es “user”
  11. 11. cancancanCanCanCommunity / cancancan Preparar cancancan en una web app gem install cancancan1 2 rails generate cancan:ability
  12. 12. cancancanCanCanCommunity / cancancan class Ability include CanCan::Ability ! def initialize(user) if user.admin?! can :manage, :all elsif user.client? can :read, :all can :manage, Article do |article| user.articles.include? article end end end end
  13. 13. cancancanCanCanCommunity / cancancan class ApplicationController < ActionController::Base rescue_from CanCan::AccessDenied do |exception| redirect_to root_url, :alert => exception.message end end
  14. 14. cancancanCanCanCommunity / cancancan <% if can? :update, @article %> <%= link_to "Edit", edit_article_path(@article) %> <% end %>
  15. 15. acts_as_api #3
  16. 16. acts_as_apifabrik42 / acts_as_api Interfaz para representaciones de modelos ! Parsear a JSON fácil y rápido ! Plantillas de inclusión de información
  17. 17. acts_as_apifabrik42 / acts_as_api Preparar acts_as_api en una web app gem install acts_as_api1 2 Modificar nuestros modelos al gusto
  18. 18. acts_as_apifabrik42 / acts_as_api class User < ActiveRecord::Base acts_as_api ! field :first_name field :last_name field :age field :email field :password ! api_accessible :public do |template| template.add :first_name template.add :age end # will render json: { "user": { "first_name": "John", "age": 26 } } end
  19. 19. acts_as_apifabrik42 / acts_as_api class UsersController < ApiController def index @users = User.all respond_with @users, api_template: :public end end
  20. 20. kaminari #4
  21. 21. kaminariplataformatec / devise Paginación a nivel backend ! Muchas configuraciones posibles
  22. 22. kaminariplataformatec / devise Preparar kaminari en una web app gem install kaminari1
  23. 23. kaminariplataformatec / devise User.page(7).per(50)
  24. 24. kaminariplataformatec / devise class UsersController < ApplicationController def index @users = User.all.per(params[:per]).page(params[:page]) respond_with @users end end GET /users?per=25&page=1
  25. 25. factory_girl_rails #5
  26. 26. factory_girl_railsthoughtbot / factory_girl_rails Integración para Rails de ‘factory_girl’ ! Factoría de entidades de modelos ! Ideal para tests
  27. 27. factory_girl_railsthoughtbot / factory_girl_rails Preparar factory_girl_rails en una web app gem install factory_girl_rails1
  28. 28. factory_girl_railsthoughtbot / factory_girl_rails FactoryGirl.define do sequence :email do |n| "user#{n}@email.com" end ! sequence :contact_name do |n| "Antonio#{n}" end end
  29. 29. factory_girl_railsthoughtbot / factory_girl_rails FactoryGirl.define do factory :user do email contact_email password “foobarfoo” end end FactoryGirl.create_list( :user, 50 ) FactoryGirl.create( :user )
  30. 30. letter_opener #6
  31. 31. Visualización de emails en el explorador ! Los emails aparecen como popups letter_openerryanb / letter_opener
  32. 32. letter_openerryanb / letter_opener Preparar letter_opener en una web app gem install letter_opener1 2 En config/environments/development.rb config.action_mailer.delivery_method = :letter_opener
  33. 33. letter_openerryanb / letter_opener Prueba no disponible! ! :(
  34. 34. delayed_job #7
  35. 35. Ejecución asíncrona de métodos ! Ejecución en segundo plano ! Calendarización de tareas delayed_jobcollective idea / delayed_job
  36. 36. delayed_jobcollective idea / delayed_job Preparar delayed_job en una web app gem install delayed_job_active_record 1 2 3 Si se usa Active Record: rails generate delayed_job:active_record gem install delayed_job_mongoid En config/application.rb: config.active_job.queue_adapter = :delayed_job
  37. 37. delayed_jobcollective idea / delayed_job @user.activate!(@device) ! @user.delay.activate!(@device)
  38. 38. delayed_jobcollective idea / delayed_job def future puts “Future is here!” end ! handle_asynchronously :future, run_at: Proc.new { 5.minutes.from_now }
  39. 39. Ruby on Rails
  40. 40. Gracias_ ! :)

×