Red > Green > Refactor > Red

cycle is based on desire

Rails Model の scope 3系 と 4系

3系 と 4系で違い

scope の書き方が変更されている。

(lambda の処理が関係してそう)

DEPRECATION WARNING: Using #scope without passing a callable object is deprecated. 

For example `scope :red, where(color: 'red')` should be changed to `scope :red, -> { where(color: 'red') }`. 

There are numerous gotchas in the former usage and it makes the implementation more complicated and buggy. 

(If you prefer, you can just define a class method named `self.red`.).
3系
class Table < ActiveModel::Base
  scope :over_two, where.('priority >= 2')
end

4系
class Table < ActiveModel::Base
  scope :over_two, -> { where('priority >= 2') }
end

アロー演算子に見えて仕方がない