Action Pack Variants – Action Mailer Previews – Spring, Rails Preloader



Action Pack Variants – Action Mailer Previews – Spring, Rails Preloader

0 0


meetup-february-2013-4-1


On Github benstevenson / meetup-february-2013-4-1

Rails 4.1 - The Nifty Bits

Ben / @bennett_stevens

Dragons Ahead

Rails 4.1 is still in Beta, and some issues(brought up later) will be present.

Action Pack Variants

Seems small but very powerful addition to the framework for API centric shops.

              
                before_action do 
                  request.variant = :phone if request.user_agent =~ /Nexus 5/
                  request.variant = :tablet if request.user_agent =~ /Nexus 7/
                end
              

                before_action is alias for before_filter
            

... continued.

              
                app/views/postings/show.html.erb
                app/views/postings/show.html+tablet.erb
                app/views/postings/show.html+phone.erb
              

              
                class PostingsController < ApplicationController
                  def show
                    @posting = Posting.find(params[:id])
                    respond_to do |format|
                      format.json

                      format.html do |html|
                        html.tablet
                        html.phone
                        html.none
                      end
                    end
                  end
                end
              
            

Action Mailer Previews

Replacement for Mailcatcher, Mailtrap, and Letter Opener in development.

              ('test' || 'spec')/mailers/previews/registration_mailer
              
                class RegistrationMailer < ActionMailer::Preview
                  def new_user
                    RegistrationMailer.registration(User.last)
                  end
                end
              
            

Become available at:

              
                http://localhost:3000/rails/mailers/registraiton_mailer/new_user
              
            

Full list at:

              
                http://localhost:3000/rails/mailers
              
            

But the other tools work already!

True, but they can still be used in staging or beta environments. Plus if this is part of the Github rails

Spring, Rails Preloader

Who uses Zeus? Who uses Spork? Who has no idea what I'm talking about?

Time Comparison