【发布时间】:2016-09-22 14:51:17
【问题描述】:
我完全迷失了这个。我正在使用 ruby 2.2.4 并将应用程序从 rails 4.1.0 升级到 4.2。该应用程序运行良好。我更改了我的 Gemfile 以使用:
gem 'rails', '~>4.2'
然后运行我的规范测试,应用程序因以下错误而崩溃:
usr/local/rvm/rubies/ruby-2.2.4/bin/ruby -I/path-to-my-app/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.5.0/lib:/path-to-my-app/vendor/bundle/ruby/2.2.0/gems/rspec-support-3.5.0/lib /path-to-my-app/vendor/bundle/ruby/2.2.0/gems/rspec-core-3.5.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
Coverage report generated for RSpec to /path-to-my-app/coverage. 22 / 1206 LOC (1.82%) covered.
/path-to-my-app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/attribute_methods/time_zone_conversion.rb:64:in `create_time_zone_conversion_attribute?': undefined method `type' for "NUMBER(38)":String (NoMethodError)
from /path-to-my-app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/attribute_methods/time_zone_conversion.rb:53:in `block (2 levels) in inherited'
当我尝试在浏览器中加载应用时出现错误:
undefined method 'type' for "NUMBER(38)":String
我对此进行了谷歌搜索,并找到了一篇帖子。它在 StackOverflow 中:NoMethodError: Undefined method 'type' for nil:NilClass in Rails,这导致我:https://gist.github.com/alsemyonov/88826/revisions
我尝试了 github 应用程序中发布的修复程序,但仍然遇到相同的错误。
错误中提到了“time_zone_conversion.rb”,我读到的一些内容让我认为这是:日期时间相关的。我在几个模型中有一种方法适用于日期字段“updated_at”。不确定这是否相关。
def updated_at_formatted
self.updated_at.strftime("%m/%d/%Y")
end
我也在使用 gem 'american_date'。
任何关于导致此问题的原因以及如何解决此问题的想法将不胜感激。
谢谢,
【问题讨论】:
标签: ruby-on-rails-4