简体   繁体   中英

date_select issue in Rails

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

根据您所发表的东西,我会说, card_expires_on在你的CREDIT_CARD方法是零。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM