Sha256: 59c7041866ee95ae11477da84ae3c7bce4f8e615dbcc3773bc7d0a7f122b9e87

Contents?: true

Size: 814 Bytes

Versions: 2

Compression:

Stored size: 814 Bytes

Contents

class User
  include Mongoid::Document

  field :login
  field :email
  field :role

  referenced_in :site, :inverse_of => :users
  references_many :articles, :foreign_key => :author_id
  references_many :comments, :dependent => :destroy, :autosave => true
  references_and_referenced_in_many :children, :class_name => "User"
  references_one :record

  embeds_one :profile

  validates :login, :presence => true, :uniqueness => { :scope => :site }, :format => { :with => /^[\w\-]+$/ }
  validates :email, :uniqueness => { :case_sensitive => false, :scope => :site, :message => "is already taken" }, :confirmation => true
  validates :role, :presence => true, :inclusion => { :in => ["admin", "moderator", "member"]}  
  validates :profile, :presence => true, :associated => true

  def admin?
    false
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongoid-rspec-1.4.4 spec/models/user.rb
mongoid-rspec-1.4.3 spec/models/user.rb