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.
--
Posted via http://www.ruby-forum.com/.
Any ideas what's going on? I'm stumped.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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
<td><%= contact.created_at.to_s(:ymd) rescue
contact.created_at.inspect %></td>
results in "nil".
Via console:
[root@server current]# ./script/console staging
Loading staging environment (Rails 2.3.5)
>> c = Contact.find 368299
=> #<Contact id: 368299, client_id: 12345, first_name: "Matt",
last_name: "Android", is_active: 1, created_at: "2009-11-12 20:47:34",
updated_at: nil, deleted_at: nil>
>> c.created_at
=> Thu, 12 Nov 2009 20:47:34 UTC +00:00
>>
Any ideas on what could be different between Rails loading the objects
for the web vs. the console?
On Feb 17, 6:09 pm, ben wiseley <wisel...@gmail.com> wrote:
> 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):
>
> #config.time_zone = 'UTC'
>
> config.active_record.default_timezone = :utc
>
> > rubyonrails-ta...@googlegroups.com<rubyonrails-talk%2Bunsu...@googlegroups.com>
So far I seem to know:
- 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.
I'm out of ideas.
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.
Thanks again!
Yes, the console is in the same environment as the app. The app is
>
> Are you started script/console in production mode?
running through passenger 2.2.9
Yes, it's fine in the database,
> When you look at
> the production database does this field have a value set?
In my view:
> Lastly, can
> you provide a code fragment?
>
<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
<td><%= contact.created_at.to_s(:ymd) rescue
contact.created_at.inspect %></td>
results in "nil".
Via console:
[root@server current]# ./script/console staging
Loading staging environment (Rails 2.3.5)
>> c = Contact.find 368299
=> #<Contact id: 368299, client_id: 12345, first_name: "Matt",
last_name: "Android", is_active: 1, created_at: "2009-11-12 20:47:34",
updated_at: nil, deleted_at: nil>
>> c.created_at
=> Thu, 12 Nov 2009 20:47:34 UTC +00:00
>>
--
:ymd is a custom format I've defined in my environment.rb.
The issue is resolved however; see a few posts above.
Thanks,
Jeff
On Feb 18, 1:31 pm, Conrad Taylor <conra...@gmail.com> wrote:
> > rubyonrails-ta...@googlegroups.com<rubyonrails-talk%2Bunsu...@googlegroups.com>