Jon Leighton

Articles

Revocable sessions with Devise »

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! »

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 »

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 »

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 »

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

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

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.

Tracking down method definitions in Ruby »

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.

Hashes and encapsulation »

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

Poltergeist: A PhantomJS driver for Capybara »

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 »

Ruby has two methods for creating shallow copies of objects:

Mass assignment security shouldn't happen in the model »

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 »

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).