class: middle, center #.num[Rails et Emails] Les 6 choses qu'il faut arrêter de faire. --- # .num[1] Arrêtez de les envoyer avec vos contrôleurs -- ```rb class NotifierPreviewsController < ApplicationController def welcome user = User.order('rand()').first render text: Notifier.welcome(user).body end end ``` --- ## Rails 4.1 ```rb class NotifierPreview < ActionMailer::Preview def welcome user = User.order('rand()').first Notifier.welcome(user) end end ``` Et visiter `/rails/mailers` en développement. --- background-image: url(https://farm4.staticflickr.com/3814/11373753906_5fdbc53f11_b.jpg) --- # .num[2] Arrêtez d'inliner les CSS à la main -- ```rb gem "premailer-rails" ``` --- background-image: url(https://farm4.staticflickr.com/3919/14815507864_cc3456c3ed_h.jpg) --- # .num[3] Arrêtez de recharger votre navigateur -- ```rb gem "rack-livereload", group: :development ``` --- background-image: url(https://farm1.staticflickr.com/7/6651408_9fd87016b3_b.jpg) --- # .num[4] Arrêtez d'envoyer vos emails tout de suite -- ```rb gem "sidekiq" ``` ??? Ou resque, delayed_job, beanstalkd, bunny, girl_friday -- Sidekiq : ```rb Notifier.delay.welcome(@user) ``` -- Rails 4.2.0.beta1 : ```rb Notifier.welcome(@user).deliver_later ``` --- background-image: url(https://farm1.staticflickr.com/117/364543602_b4efb3a617_b.jpg) --- # .num[5] Arrêtez d'envoyer des emails -- ```rb gem "letter_opener", group: :development ``` --- background-image: url(https://farm1.staticflickr.com/148/355803586_d610061e55_b.jpg) --- # .num[6] Arrêtez de configurer vos URLs -- ```rb gem "action_mailer_auto_url_options" ``` --- background-image: url(https://farm4.staticflickr.com/3615/3489950787_cbfa4faab4_b.jpg) --- class: middle, big ```rb gem "rails", "~> 4.2.0.beta1" gem "premailer-rails" gem "rack-livereload", group: :development gem "sidekiq" gem "letter_opener", group: :development gem "action_mailer_auto_url_options" ``` --- background-image: url(http://wtf.sunfox.org/vendredi/peach-bubbles.jpg) class: middle, inverse, shadow, big # # Merci ! Sunny Ripert Cosmic github.com/sunny @sunfox PS : Ceci est un chat. <style>.shadow{ text-shadow:2px 2px 2px rgba(0,0,0,.3) }</style> <style>.remark-slide-content { background-size: cover !important}</style> <style>.remark-slide-number {display: none;}</style> <style>.big code, .big p{font-size:1.3em}</style> <style>.inverse{color:white;background-color:black}</style> <style>.num{color:purple}</style} <style>.remark-slide-content h1{font-size:54px !important}</style>