class User include SimplyStored::Couch include Devise::Orm::SimplyStored property :active_list_id devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable, :token_authenticatable has_and_belongs_to_many :lists, storing_keys: false has_many :orders validates_uniqueness_of :email before_save :ensure_authentication_token view :by_authentication_token, key: :authentication_token view :by_email, key: :email def list_is_closed! self.active_list_id = nil save end def has_active_list? active_list_id.present? end end