Sha256: 140759b49f75a4b91b6e06e5302c4549b7366710db898f9bb2c183b2cee8650a
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
class User include Mongoid::Document include Mongoid::Timestamps::Created field :login field :email field :role field :age, type: Integer field :password, type: String field :provider_uid field :locale belongs_to :site, :inverse_of => :users has_many :articles, :foreign_key => :author_id, :order => :title has_many :comments, :dependent => :destroy, :autosave => true has_and_belongs_to_many :children, :class_name => "User" has_one :record, :autobuild => true embeds_one :profile validates :login, :presence => true, :uniqueness => { :scope => :site }, :format => { :with => /^[\w\-]+$/ }, :exclusion => { :in => ["super", "index", "edit"]} 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 validates :age, :presence => true, :numericality => true, :inclusion => { :in => 23..42 }, :on => [:create, :update] validates :password, :presence => true, :on => [:create, :update] validates :provider_uid, presence: true validates :locale, :inclusion => {:in => lambda { |user| [:en, :ru] } } attr_accessible :login, :email, :age, :password attr_accessible :role, :as => :admin accepts_nested_attributes_for :articles, :comments def admin? false end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mongoid-rspec-1.8.2 | spec/models/user.rb |
mongoid-rspec-1.8.1 | spec/models/user.rb |
mongoid-rspec-1.8.0 | spec/models/user.rb |