Sha256: 48fbfd390ed199157f3dbb62e9e7adbbfc1634f157c86e5fc4f20a60eebbb6c5

Contents?: true

Size: 858 Bytes

Versions: 1

Compression:

Stored size: 858 Bytes

Contents

class User < ActiveRecord::Base
  has_many :posts
  has_many :dogs, :foreign_key => :owner_id

  has_many :friendships
  has_many :friends, :through => :friendships

  has_one :address, :as => :addressable

  named_scope :old,      :conditions => "age > 50"
  named_scope :eighteen, :conditions => { :age => 18 }
  named_scope :recent,   lambda {|count| { :limit => count } }

  def self.recent_via_method(count)
    scoped(:limit => count)
  end

  attr_protected :password
  attr_readonly :name

  validates_format_of :email, :with => /\w*@\w*.com/
  validates_length_of :email, :in => 1..100
  validates_inclusion_of :age, :in => 1..100
  validates_acceptance_of :eula
  validates_uniqueness_of :email, :scope => :name
  validates_length_of :ssn, :is => 9, :message => "Social Security Number is not the right length"
  validates_numericality_of :ssn
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
technicalpickles-shoulda-2.0.0 test/rails_root/app/models/user.rb