May 252016
def wait_for_ajax
 counter = 0
 while page.evaluate_script(“typeof($) === ‘undefined'”)
  counter += 1
  print “^”
  raise “Jquery not initialized after 10 seconds.” if counter >= 100

 counter = 0
 while page.evaluate_script(“$.active > 0”)
  counter += 1
  print “_”
  if counter >= 100
   msg = “AJAX request took longer than 10 seconds.”
   if page.driver.respond_to?(:console_messages)
    msg << ” console messages at time of failure: ” + page.driver.console_messages.inspect
   raise msg

May 212016

First, on Heroku, you’ll need to add a special buildpack to your slug:

(note that all of the following commands you may need to append with -a if you manage more than one Heroku app)

heroku buildpacks:add -i 1

(Here -i 1 tells the command you want the buildpack at index 1. It’s important that you include this flag or else the Heroku API will add your buildpack before the default build, which is known simply as heroku/ruby)

(If you’d prefer to use ImageMagick 7.0.24, I’ve also made a buildpack for that available here:

You can and should examine what you just added with:

To examine what you just did:

heroku buildpacks

You should see the response:

$ heroku buildpacks:add -i 1

Buildpack added. Next release on app-xyz will use:
 2. heroku/ruby
Run git push heroku master to create a new release using these buildpacks.

To undo what you just did

heroku buildpacks:remove

Then push your app to your repo. You will notice it takes a few minutes to compile the new ImageMagick binary and install it into the slug.

You can set the :convert_options in your paperclip definitions, or to make a global change to all your definitions use a monkeypatch like so:

Create a file for paperclip init if you don’t already have one


Monkeypatch the Paperclip processor with the resize filter of your choice.

module Paperclip
 class Processor
def convert(arguments = “”, local_options = {})
 if (arguments =~ /-resize/)
  arguments.sub!(“-resize”, “-filter Lanczos -resize”)
 end‘convert’, arguments, local_options)

You can read all about the kinds of filters here.