Q:

Calculating sum of two columns with individual rows and result store in another column USing ruby on rails

I am new to Ruby on rails platform, I have a question i.e., In my module i have table called Asset_classification in which name, type, availability, integerity, level are the fields. i want to calculate(sum) integrity & level fields  for each row and finally result should be store in another column....
Any help is appreciate
Ruby 1.9.3
Rails 3.2.*

A:

Add new column sum in database and do this in AssetClassification model
before_save :calculate_sum

def calculate_sum
  self.sum = self.integrity + self.level
end

