change scoped and use references to fix deprecation warning in Rails 4