refactoring code after the rails version changes.