Exception: LowCardTables::Errors::LowCardStaticScopeError

Inherits:
LowCardError
  • Object
show all
Defined in:
lib/low_card_tables/errors.rb

Overview

Raised when you try to define a scope involving a low-card table in a static way, rather than dynamic. (e.g., you say, in class User, scope :alive, where(:deleted => false)) These scopes have their ‘where’ definitions evaluated only once, at class definition time, and, as such, cannot ever pick up any new IDs of low-card rows that later get created that match their definition. As such, we completely disallow their creation, and raise this error if you try.

The solution is trivial, and is to define them dynamically – scope :alive, -> { where(:deleted => false) }. This is what ActiveRecord >= 4.0 requires, anyway – the static form is deprecated.