【问题标题】:ActionView::Template::Error (undefined method `getlocal' for "2008-02-14T02:20:50Z":String):ActionView::Template::Error(“2008-02-14T02:20:50Z”:String 的未定义方法 `getlocal'):
【发布时间】:2012-07-20 19:54:47
【问题描述】:

更新 Mongoid 3.0.1 / Rails 3.2.6 后,在显示 created_at 时开始出现“getlocal”方法错误:

Showing /home/lsoave/rails/github/gitwatcher/app/views/shared/_watch-list-table.html.haml where line #28 raised: 

undefined method `getlocal' for "2008-02-14T02:20:50Z":String

Extracted source (around line #28): 

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

更新

我有一个设置格式的 config/initializers/time_formats.rb

$ cat config/initializers/time_formats.rb

Time::DATE_FORMATS[:month_and_year] = "%B %Y"
Time::DATE_FORMATS[:pretty] = lambda { |time| time.strftime("%a, %b %e at %l:%M") + time.strftime("%p").downcase }

无论如何,只要调用repo.created_at(省略.to_s(:pretty))也会发生错误

更新

我刚刚在 RVM/Ruby - Rails - Mongoid 堆栈上尝试回滚,但没有成功:

from ruby-1.9.3-p194@rails-3.2.6 to ruby-1.9.2-p290@rails-3.2.3

from Mongoid 3.0.1 to Mongoid 2.4.3

from Rails 3.2.6 to Rails 3.2.3 

查看 RVM 输出:

lsoave@ubuntu:~/rails/tests/gitwatcher$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
lsoave@ubuntu:~/rails/tests/gitwatcher$ rvm list

rvm rubies

=> ruby-1.9.2-p290 [ i686 ]
 * ruby-1.9.3-p194 [ i686 ]

# => - current
# =* - current && default
#  * - default

lsoave@ubuntu:~/rails/tests/gitwatcher$ rvm gemset list

gemsets for ruby-1.9.2-p290 (found in /home/lsoave/.rvm/gems/ruby-1.9.2-p290)
   global
=> rails-3.2.3

lsoave@ubuntu:~/rails/tests/gitwatcher$ 

...我在这一点上客串了 ENV 级别的东西,但是什么?

【问题讨论】:

标签: ruby-on-rails ruby rubygems mongoid rvm


【解决方案1】:

您的数据可能有问题。

【讨论】:

    猜你喜欢
    • 2015-06-11
    • 1970-01-01
    • 1970-01-01
    • 2013-04-10
    • 2015-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多