I have a rails 2.3.5 app running on ruby 1.8.7 (2008-08-11 patchlevel
72) [i686-darwin9] locally, and everything is fine.
I'm trying to deploy it to my server, running centos 5.4, ruby 1.8.7
(2009-12-24 patchlevel 248) [x86_64-linux], MBARI 0x6770, Ruby
Enterprise Edition 2010.01.
When I retrieve records via the app, the created_at is nil. I can
pull the same records through script/console and created_at is
properly set as expected. Through the app though, object.created_at
is nil, object.attributes['created_at'] is nil, but
object.created_at_before_type_cast returns the proper string from the
database.
I have a rails 2.3.5 app running on ruby 1.8.7 (2008-08-11 patchlevel
72) [i686-darwin9] locally, and everything is fine.
I'm trying to deploy it to my server, running centos 5.4, ruby 1.8.7
(2009-12-24 patchlevel 248) [x86_64-linux], MBARI 0x6770, Ruby
Enterprise Edition 2010.01.
When I retrieve records via the app, the created_at is nil. I can
pull the same records through script/console and created_at is
properly set as expected. Through the app though, object.created_at
is nil, object.attributes['created_at'] is nil, but
object.created_at_before_type_cast returns the proper string from the
database.
Any ideas what's going on? I'm stumped.
What database are you using? MySQL, PosgreSQL, etc.) I don't see it
listed here.
Are you started script/console in production mode?
Yes, the console is in the same environment as the app. The app is
running through passenger 2.2.9
When you look at
the production database does this field have a value set?
Yes, it's fine in the database,
Lastly, can
you provide a code fragment?
In my view:
<td><%= contact.created_at.to_s(:ymd) %></td>
Which results in:
ActionView::TemplateError (wrong number of arguments (1 for 0)) on
line... pointing at the line above, because 'created_at' is nil. I
know this because changing it to
I don’t know if this is related but I spent half my morning trying to figure out why I was getting nil.include? errors for date fields only after reloading the page (Ruby 1.8.7, Rails 2.3.5). This was the fix (in env.rb):
Yeah, I have both of those lines in my environment.rb too. Commenting
out the first doesn't seem to help my issue though, but thanks for the
attempt. I'm going to try reverting to Ruby 1.8.6 next.
- It isn't the ruby version, as it happens under 1.8.6, 1.8.7 and 1.9
- It isn't the webserver, as it happens with Passenger and Webrick
This would suggest it's my app, yet the exact same app works as
expected on my macbook in both development and test mode. Also the
fact that on the server, I can issue the exact same statement that the
controller is issuing, and I get my datetime fields parsed into ruby
datetimes as expected, yet via the webserver it does not work.
You were right after all! I had in my application controller a line
where I was also setting ActiveRecord::Base.default_timezone.
Removing this fixed it.