Jon Leighton


Square pegs, round holes, and Rails' directory structure »

16 March 2017

Where should you put code in your Rails application? Often, the answer is obvious: models go in app/models/, controllers go in app/controllers/, and so on.

Overhauling Loco2's hosting infrastructure with AWS, Docker and Terraform »

16 December 2016

Recently I worked on a major overhaul of the infrastructure hosting In this post, I’ll dig into the details of what we did and why.

Revocable sessions with Devise »

10 October 2013

By default, session data in Rails is stored via a cookie in the user’s browser. It’s a nice, simple storage mechanism, but it means that the server has absolutely no “memory” of a given session. This can cause security problems for your application.

Poltergeist 1.0! »

7 October 2012

Almost a year ago, on a complete whim, I decided to try to hook up the headless browser PhantomJS with Ruby’s full-stack acceptance testing framework, Capybara.

Explaining Focused Controller »

20 September 2012

Controllers in Rails are a problem. Actions sometimes become unmanageably long, and it’s often difficult to know how to test them when you need it most. At Railsberry in May, I presented a new way of writing controllers.

Rails controllers and OOP »

20 April 2012

Rails controllers violate the Single Responsibility Principle. Each “action” has a different responsibility and should be contained in a separate object. Controllers are also hard to unit test, so we end up using slow “functional tests”.

Poltergeist 0.6.0: Javascript error handling and remote debugging »

15 April 2012

Recently I pushed version 0.6.0 of Poltergeist. This version brings some pretty awesome features that I am very excited about.

Tracking down method definitions in Ruby »

19 February 2012

One of my favourite features of Ruby 1.9 is the #source_location method of Proc and Method. Let me explain. Often I am confronted with a large code base (usually Rails), and want to figure out exactly where some method on some object is defined. Rails has many dark corners, and sometimes finding things isn’t entirely straightforward.

How to prevent Ruby's test/unit library from autorunning your tests »

19 February 2012

Today I had a situation where I wanted to use perftools.rb to profile a test suite, which was written with Ruby’s test/unit library.

Hashes and encapsulation »

9 January 2012

Earlier today I made an off-the-cuff remark about encapsulation on twitter.

Poltergeist: A PhantomJS driver for Capybara »

3 January 2012

This announcement is coming way later than I had originally intended. Last October I started experimenting with the idea of writing a driver for Capybara that would use PhantomJS as the browser.

initialize_clone, initialize_dup and initialize_copy in Ruby »

30 August 2011

Ruby has two methods for creating shallow copies of objects:

Mass assignment security shouldn't happen in the model »

14 August 2011

Mass assignment security is a feature in Active Model (and therefore Active Record) which allows you to be selective about what input you will accept when ‘mass assigning’ a hash of attributes.

How to write an awesome Active Record bug report »

10 July 2011

The main area of Ruby on Rails that I work on is Active Record. As such, I see a lot of bug reports for Active Record. This article will be about how to submit a good bug report to help people like me (Rails committers) help people like you (bug inflicted developers).