I'm trying to create a new date from form values and assign it to a variable.
Here's the code I have so far:
eventDate = Date.new(params[:event]["date(1i)"],params[:event]["date(2i)"],params[:event]["date(3i)"])
However, I get the following error:
ArgumentError in EventsController#create
comparison of String with 0 failed
I have no idea what this means.
Any ideas?
Thank you,
Brian
The problem is that Date.new (which actually calls Date.civil) requires that you pass integers, and you are passing strings. Try:
eventDate = Date.new(params[:event]["date(1i)"].to_i,params[:event]["date(2i)"].to_i,params[:event]["date(3i)"].to_i)
You are using Strings. Try this:
eventDate = Date.new(params[:event]["date(1i)"].to_i,params[:event]["date(2i)"].to_i,params[:event]["date(3i)"].to_i)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With