Hello All,

My problem is i have field "expiry_date" which is  a "date" type.
I want to take that date and store it in database as following


in controller
-----------------------------------
def create

      cc_information = params[:credit_card]
      @credit_card = CreditCard.new
      @credit_card.first_name = cc_information['first_name']
      @credit_card.last_name = cc_information['last_name']
      @credit_card.cc_number = cc_information['cc_number']
      .........
      .........

      @credit_card.expiry_date =
Date.civil(cc_information['expiry_date(1i)'],
cc_information['expiry_date(2i)'], cc_information['expiry_date(3i)'])

end


I can use this also @credit_card = CreditCard.new(params[:credit_card])

But I don't want it. I want to store "expiry_date" using Date.civil or
Date.civil_to_jd

but it throws me error
-------------------------------------------------------------
 ArgumentError in Credit cardsController#create

comparison of String with 0 failed

RAILS_ROOT: D:/subscription_manegement
Application Trace | Framework Trace | Full Trace

c:/ruby/lib/ruby/1.8/date.rb:596:in `<'
c:/ruby/lib/ruby/1.8/date.rb:596:in `valid_civil?'
c:/ruby/lib/ruby/1.8/date.rb:726:in `civil'
D:/subscription_manegement/app/controllers/credit_cards_controller.rb:52:in
`create'
-----------------------------------------------------------------------






In view new.html.erb
--------------------------


<% form_for :credit_card, @credit_card, :url => credit_cards_path, :html
=>{:method => :post} do |f| %>
  <%= f.error_messages %>

......
....... other fields

<p>
    <%= f.label :expiry_date %><br />
    <%= f.date_select :expiry_date %>
  </p>



please tell me Where I am doing wrong?


Thanks,
Vikas
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to