Rails4 adapter

The rebased, mergeable version of #72 

Thanks so much @scpike!