wholesale refactor into Rails 4