Forum: Ruby on Rails date type in database becomes nil in rails

22b6c2e39df33aa17c8ea72eb5dd100e?d=identicon&s=25 Ichiro Saga (bluegreen)
on 2011-03-03 00:24
Hi, there.  I wrote an application in Windows and tried to run it in
Ubuntu 10.04 64-bit.  The app works fine in windows but I found a
strange problem when I tested it in Ubuntu.  Two tables in database have
a column with date type and sqlite3 is able to display the data in the
column.  However, as I run it from the browser or rails console, all
data in the column becomes nil.  The ROR settings are the same in both
OS except that fact that it's running sqlite3 3.6.22 in Ubuntu and
3.6.17 in Windows.  I wonder if it has something to do with the setting
in Ubuntu.  Thank you in advance.

Ichiro
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2011-03-03 09:25
(Received via mailing list)
On 2 March 2011 23:24, Ichiro Saga <lists@ruby-forum.com> wrote:
> Hi, there. I wrote an application in Windows and tried to run it in
> Ubuntu 10.04 64-bit. The app works fine in windows but I found a
> strange problem when I tested it in Ubuntu. Two tables in database have
> a column with date type and sqlite3 is able to display the data in the
> column. However, as I run it from the browser or rails console, all
> data in the column becomes nil. The ROR settings are the same in both
> OS except that fact that it's running sqlite3 3.6.22 in Ubuntu and
> 3.6.17 in Windows. I wonder if it has something to do with the setting
> in Ubuntu. Thank you in advance.

I think you will have to give us a lot more information.  Post the
section from db/schema.rb for the offending table, post the model.rb
(remove any irrelevant methods you have included, but if you have
included a method with a name like the column that does not work then
include that) and post the result of entering, in the console,
model.first or something similar which should fetch a valid record.

Colin
22b6c2e39df33aa17c8ea72eb5dd100e?d=identicon&s=25 Ichiro Saga (bluegreen)
on 2011-03-03 19:01
> I think you will have to give us a lot more information.  Post the
> section from db/schema.rb for the offending table, post the model.rb
> (remove any irrelevant methods you have included, but if you have
> included a method with a name like the column that does not work then
> include that) and post the result of entering, in the console,
> model.first or something similar which should fetch a valid record.
>
> Colin

Thanks for your reply, Colin.  I found the workaround that's to change
the type from date to datetime.  It's so strange that even if I created
a new app in Ubuntu with date type in the model, same problem occurred.

Ichiro
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.