Forum: Ruby on Rails ActiveRecord date field

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
45bf2a9ef6df3b70ac3482015231ef4d?d=identicon&s=25 Avery Wilkening (efoo)
on 2016-05-05 17:25
By accident, I just realized that an ActiveRecord date field can be set
using a third way...

foo = Fo.new
foo.start_date = Date.new(2016, 1, 31)
foo.start_date = '2016-01-31'

and to my surprise...

foo.start_date = '31/1/2016'

Where can I find documentation on this? I've searched to the point of
wasting my time.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2016-05-05 18:15
(Received via mailing list)
On Thursday, May 5, 2016 at 4:26:19 PM UTC+1, Ruby-Forum.com User wrote:
>
> By accident, I just realized that an ActiveRecord date field can be set
> using a third way...
>
> foo = Fo.new
> foo.start_date = Date.new(2016, 1, 31)
> foo.start_date = '2016-01-31'
>

> and to my surprise...
>
> foo.start_date = '31/1/2016'
>
> Where can I find documentation on this? I've searched to the point of
> wasting my time.
>
>
In the most general case, active record ends up calling Date._parse
(
http://ruby-doc.org/stdlib-2.3.1/libdoc/date/rdoc/...
) from the ruby stdlib which tries to guess/handle all sorts of
different
formats  ( https://github.com/ruby/ruby/blob/trunk/ext/date/d...
)
but without documenting what they are (as far as I can see)

Fred
797ef431a5e1295b56c08e1db4c8d2df?d=identicon&s=25 Botp Botp (botp)
on 2016-05-05 19:00
(Received via mailing list)
On Thu, May 5, 2016 at 11:25 PM, Avery Wilkening <lists@ruby-forum.com>
wrote:
> Where can I find documentation on this?

there are lots, try this eg
https://robots.thoughtbot.com/how-rails-works-type-casting
just remember, this is ruby, and "foo=" can be a method call.

kind regards --botp
This topic is locked and can not be replied to.