Files
mozo-backend/app/models/user.rb
T
2012-09-18 15:48:32 +02:00

25 lines
562 B
Ruby

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
def list_is_closed!
self.active_list_id = nil
save
end
def has_active_list?
active_list_id.present?
end
end