Module: Barker::Validations::NumericalityOfId

Included in:
Answer, Question
Defined in:
lib/barker/validations.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/barker/validations.rb', line 4

def self.included(base)
  base.validate :numericality_of_id
end

Instance Method Details

#numericality_of_idObject



8
9
10
11
# File 'lib/barker/validations.rb', line 8

def numericality_of_id
  self.class.validates :id, :numericality => { :only_integer => true }
  errors.add(:id, 'is not a number') if id.kind_of? String
end