I was going through Ryan Bates video on Active Merchant integration video Railscast #145 and my question was regarding the creation of the @credit_card method that he defines within the Order.rb method.
def credit_card
@credit_card||=ActiveMerchant::Billing::CreditCard.new(
:type=>card_type,
:number=>card_number,
:verification_value=>card_verification,
:month=>card_expires_on.month,
:year=>card_expires_on.year,
:first_name=>first_name,
:last_name=>last_name
)
end
What I don t follow is how does this method get called. The form_for in the new method creates an @order object while and there is no mention of the credit_card method. How does the credit_card method get called to initiate the creation of the @credit_card object.
I am aware of virtual attributes but I dont know how the credit_card method is actually called.