将RoR从5.0.0降级到4.2.1:ActiveSupport的未定义方法`to_time_preserves_timezone =':模块

时间:2016-08-15 16:31:47

标签: ruby-on-rails ruby-on-rails-4 ruby-on-rails-5

我目前正在尝试将我的RoR应用程序从5.0.0降级到4.2.1,因为像activeadmin这样的某些gem似乎不能很好地与5.0.0一起使用。

然而,我收到此错误,遗憾的是,在执行 rake db:migrate

时,我并没有真正告诉我
undefined method `to_time_preserves_timezone=' for ActiveSupport:Module

这就是我的Gemfile的样子:

来源'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Postgress
gem 'pg'
# Authentication
gem 'devise'

# Use activeadmin for administration
gem 'activeadmin', github: 'activeadmin'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Slim support
gem "slim-rails"
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported      runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more:    https://github.com/turbolinks/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more:    https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

# Use Bootstrap forms
gem 'bootstrap_form'

# gem 'capistrano-rails', group: :development
gem 'rails_12factor', group: :production

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a     debugger console
gem 'byebug'

# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'

end

非常感谢您提出任何想法。

3 个答案:

答案 0 :(得分:4)

删除Gemfile.lock并运行'bundle install'将安装以gemfile编写的最新版本的gem,除非指定了version。这可能会导致版本4.2.1的兼容性问题。

由于Rails 5.0的升级,这可能是一个问题。请确保项目目录不包含支持Rails 5的配置文件。

答案 1 :(得分:1)

首先......哎呀。降级永远不会有趣。

gem list并查看列出的activesupport版本。 Rails 4.2.1将需要先前版本activesupport 4.2.1以及一堆其他宝石。

您可能希望在此之后删除Gemfile.lockbundle install,然后将获取正确的版本。我保证这会很混乱,但核心轨道宝石至少应该降级。

编辑:我也猜测你的项目中会有Rails 5.0依赖项,然后在回滚过程中会中断,所以这甚至可能无法完全解决你的问题。不过值得一试。

答案 2 :(得分:0)

我通过注释掉config / initializers / new_framework_defaults.rb解决了这个问题。该文件是Rails 5的一部分。一切似乎都在后续工作。