Hi I am a complete newbie getting my feet with Rails, Please can someone help me in understanding the flow of the code
How CreditCardCallbacks, def before_validation(model) is invoked when we are not calling it directly.
class CreditCardCallbacks
# Normalize the credit card number
def before_validation(model)
model.cc_number.gsub!(/[-\s]/, '' )
end
end
class Order < ActiveRecord::Base
before_validation CreditCardCallbacks.new
# ...
end
class Subscription < ActiveRecord::Base
before_validation CreditCardCallbacks.new
# ...
end
Thanks in advance