Rails4: Can't modify frozen hash
On the line that gets highlighted you should make sure that sale
is not destroyed when updating its price
attribute:
self.price = mrr * quantity.to_f unless destroyed? # notice, no need for self before quantity
# or
write_attribute(:price, mrr * quantity.to_f) unless destroyed?