我在我的视图中实现了date_select,当我访问模型时,它给了我错误:
查看:
<%= 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]%>
型号:
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
错误:
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.month
答案 0 :(得分:2)
根据您发布的内容,我会说您的credit_card方法中的card_expires_on
为零。