Can't print created_at timestamp. undefined method `getlocal'...

Showing 1-7 of 7 messages
Can't print created_at timestamp. undefined method `getlocal'... Tronic 7/11/12 1:37 AM
hi.

i think this is an mongoid issue. when i add mongoid timestamps to my model and want to print the created_at timestamp in one of my views, i get the following error:

undefined method `getlocal' for "Wed, 11 Jul 2012 02:39:24 -0400":String
any advice on this?

thanks!


Re: [mongoid] Can't print created_at timestamp. undefined method `getlocal'... Durran Jordan 7/11/12 1:48 AM
Can I see the model and view code please?

2012/7/11 Tronic <clemens...@gmail.com>

Re: [mongoid] Can't print created_at timestamp. undefined method `getlocal'... Tronic 7/11/12 2:05 AM
model:

class App
  include Mongoid::Document
  include Mongoid::Timestamps

  field :name, :type => String
  field :bundle, :type => String
  field :license, :type => String
  field :auth_count, :type => Integer
  field :type, :type => Integer, :default => 0
  field :active, :type => Boolean, :default => true
  
  validates_uniqueness_of :name, :case_sensitive => false
  
  belongs_to :user
  has_one :order
end


view code:

<%= @app.created_at %>

Am Mittwoch, 11. Juli 2012 10:48:32 UTC+2 schrieb Durran Jordan:
Re: [mongoid] Can't print created_at timestamp. undefined method `getlocal'... Luca G. Soave 7/16/12 1:56 PM

It happen to me too during an update flow Rails 3.2.3 --> 3.2.6 / Mongoid 3.0.1 ...
here it is another similar case on stackoverflow
Re: [mongoid] Can't print created_at timestamp. undefined method `getlocal'... Luca G. Soave 7/16/12 3:08 PM

I guess something goes wrong with a mixin somewere :

lsoave@ubuntu:~/rails/github/gitwatcher$ rails c
Loading development environment (Rails 3.2.6)
1.9.3-p194 :001 > Time.now.getlocal
 => 2012-07-17 00:00:15 +0200
1.9.3-p194 :002 > DateTime.now.getlocal
NoMethodError: undefined method `getlocal' for Tue, 17 Jul 2012 00:02:45 +0200:DateTime
    from (irb):2
    from /home/lsoave/.rvm/gems/ruby-1.9.3-p194@rails-3.2.6/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start'
    from /home/lsoave/.rvm/gems/ruby-1.9.3-p194@rails-3.2.6/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start'
    from /home/lsoave/.rvm/gems/ruby-1.9.3-p194@rails-3.2.6/gems/railties-3.2.6/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
1.9.3-p194 :003 >

my offending string is in 28 line @ app/views/shared/_watch-list-table.html.haml which is :

28:           %td= repo.created_at.to_s(:pretty)

and it used working before ...
Re: [mongoid] Can't print created_at timestamp. undefined method `getlocal'... Durran Jordan 7/16/12 11:33 PM
Yeah I'm still looking into this - created_at should be a Time, not a DateTime, and is defined as such in Mongoid's module.

2012/7/17 Luca G. Soave <luca....@gmail.com>

Re: [mongoid] Can't print created_at timestamp. undefined method `getlocal'... Luca G. Soave 7/21/12 7:36 AM


It's not a mongoid/moped issue, there were a data corruption, probably caused by switching between branches with different mongoid - mongo/moped versions, with the mongodb opened and connected ...

I just dropped the database and mongorestore a backup, to solve the problem.