update code to fix rails 4 deprecations