Rails 4 compatible. First try. Tests passing.