Hi all, I'm using the doc at http://apidock.com/ to help me learn RoR and I'm afraid about a usefull callback that seems not to exsist anymore : before_save
The doc says : This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.
But it does not say what's the new method to use and I cannot find info on the net.
I'm trying to use before_save in a product class :
class Product < ActiveRecord::Base validates_presence_of :title, :description, :image validates_numericality_of :price validates_uniqueness_of :title before_save :validate def self.find_products_for_sale find(:all, :order => "title") end protected def validate errors.add(:price, "Must be at least 0.01") if price.nil? || price < 0.01 end end
Can someone tell me what is the method to use with rails 4+ ?