Ruby on Rails Friday, May 29, 2015



On Thursday, May 28, 2015 at 8:26:39 PM UTC+2, Zakarias Santanu wrote:
Hi,

I've just started rails 4.2.1 and i created a model

And i ran

Auction.new(start_date: "foo") # false

also

Auction.new(start_date: 200.to_s) #false
Auction.new(start_date: '200') # false

Auction.new(start_date: 200)          # ArgumentError: argument out of range
Auction.new(start_date: 2000.to_s) # ArgumentError: argument out of range

Not sure, but is it a bug ?

Without knowing  what type is your start_date of, I suppose it should be date. Your are trying to pass in a String instead.
Another question is about validation. may be you have some validation rules on start_date attribute in your Auction model ad it fails to pass the validation, that's why you get 'false' in return.
Post some more details (start_date attribute type, validations to be applied, etc.) about your model to be able to help you.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fbbc726f-f56a-4bf1-8f22-f41c621035e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

2 comments:

jegan said...

http://chennaitraining.in/sap-cs-training-in-chennai/
http://chennaitraining.in/sap-ec-training-in-chennai/
http://chennaitraining.in/sap-ecm-training-in-chennai/
http://chennaitraining.in/sap-ehs-training-in-chennai/
http://chennaitraining.in/sap-ep-training-in-chennai/
http://chennaitraining.in/sap-erp-training-in-chennai/
http://chennaitraining.in/sap-ess-training-in-chennai/

KARTHIK said...

http://chennaitraining.in/sap-tr-training-in-chennai/
http://chennaitraining.in/sap-rem-training-in-chennai/
http://chennaitraining.in/sap-cs-training-in-chennai/
http://chennaitraining.in/sap-le-training-in-chennai/
http://chennaitraining.in/sap-ehs-training-in-chennai/
http://chennaitraining.in/sap-srm-training-in-chennai/
http://chennaitraining.in/sap-pm-training-in-chennai/

Post a Comment