Sha256: cb48f9dc3fd93d422ae04e12f98d760faf78f5e311a44538d9488ec79fa25c7b

Contents?: true

Size: 494 Bytes

Versions: 1

Compression:

Stored size: 494 Bytes

Contents

class Friending < ActiveRecord::Base
  belongs_to :friendee, :class_name=>'User'
  belongs_to :friendor, :class_name=>'User'
  validates_uniqueness_of :friendee_id, :scope=> :friendor_id
  validate :not_friending_self

  def confirm
    self.update_attributes(:confirmed=>true)
  end

  def reject
    self.update_attributes(:rejected=>true)
  end

private
  def not_friending_self
    errors.add(:friendee_id, "can't be the same as friendor_id") if
      friendee_id == friendor_id
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
social_engine-0.0.1 app/models/friending.rb