-1

I previously used default_scope :order => 'group_name' because I wanted it for all uses.

This doesn't work in Rails 4

I tried

scope :default, -> { order('group_name')}

which didn't raise a syntax error, but also didn't work - groups are not ordered by name

I can add a scope but I'd like to know if there's a replacement for all as a default.

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
  • No syntax error was raised since what you tried correctly creates a scope named `default`. So now you can say, `MyActiveRecord.default` and you'll get your active record ordered by `group_name`. :) – lurker Aug 19 '14 at 00:24

2 Answers2

2

Should be declared as

default_scope {order('group_name')}
Brennan
  • 5,632
  • 2
  • 17
  • 24
0

Don't do it!

But if you have to:

default_scope { order('group_name') }

From: http://api.rubyonrails.org/classes/ActiveRecord/Scoping/Default/ClassMethods.html#method-i-default_scope

Brad Werth
  • 17,411
  • 10
  • 63
  • 88