Forum: Ruby on Rails Rails, Postgres and the 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.
Fernando L. (Guest)
on 2006-05-11 00:32
(Received via mailing list)
Hi guys,

I'm having problems with my app. First of all, I created a date_select
with the code:

<%= date_select('contact', 'birthday', :order => ['day','month','year'])
%>

In the contacts table, I create a date field:

birthday DATE

When I save the values goes wrong into the database. From the log:

INSERT INTO contacts ("name", "nickname", "home_page", "mobile",
"birthday", "phone", "user_id", "address", "email") VALUES('test',
'test', 'test', 12345, '0010-01-01', 12345, 2, 'test', 
'removed_email_address@domain.invalid');

I already put the following code in my environment.rb.

ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
:default => '%m/%d/%Y',
:date_time12 => "%m/%d/%Y %I:%M%p",
:date_time24 => "%m/%d/%Y %H:%M",
)

And the date are still displayed as year, month, day.


How can I change this behavior?

Thanks in advance.

Fernando L.
Fernando L. (Guest)
on 2006-05-11 01:03
(Received via mailing list)
Fernando L. wrote:
> birthday DATE
The type DATE doesn't work well with rails. I change the type to
timestamp and it worked in the view. Even changing the type of the
column, I still have problems recording its values .

Just if I put the date_select in the format:

<%= date_select('contact', 'birthday', :order => ['year','month','day']

It works...

How can I change this to work accordingly with my app?

Thanks,

Fernando L.
Fernando L. (Guest)
on 2006-05-11 01:03
(Received via mailing list)
Fernando L. wrote:
> The type DATE doesn't work well with rails. I change the type to
> timestamp and it worked in the view. Even changing the type of the
> column, I still have problems recording its values .
>
> Just if I put the date_select in the format:
>
> <%= date_select('contact', 'birthday', :order => ['year','month','day']
>
> It DOES NOT works...

Fernando L.
This topic is locked and can not be replied to.