Reputation: 1118
I have implemented date_select in my views when i access it in to model it gives me error:
View:
<%= date_select :transaction ,:card_expires_on,:discard_day => true, :start_year => Date.today.year, :end_year => (Date.today.year+10), :add_month_numbers => true, :order => [:month,:year]%>
Model:
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
error:
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.month
Upvotes: 0
Views: 388
Reputation: 51697
Based on what you've posted, I'd say that card_expires_on
in your credit_card method is nil.
Upvotes: 2