cherrypick of cfa44149dda53c0544e70e4d08d4205a095f32ba from @gmanley
riff off of 5c584d665cf2ef55a8589a3bb6c699afec8d7c74 from @gmanley to support rails 3 and 4 simultaneously