Refactor code that raises deprecating warnings in Rails 4