我正在try 在Rails 4.0.8中运行新创建的项目,但收到以下错误:

    rails s
=> Booting WEBrick
=> Rails 4.0.8 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
/usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
/usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
Exiting
/usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:124:in `block (2 levels) in <class:Numeric>': stack level too deep (SystemStackError)
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
    from /usr/local/lib/ruby/gems/2.4.0/gems/activesupport-4.0.8/lib/active_support/core_ext/numeric/conversions.rb:131:in `block (2 levels) in <class:Numeric>'
     ... 5532 levels...
    from /usr/local/lib/ruby/gems/2.4.0/gems/railties-4.0.8/lib/rails/commands.rb:71:in `tap'
    from /usr/local/lib/ruby/gems/2.4.0/gems/railties-4.0.8/lib/rails/commands.rb:71:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Ruby版本:

Rails 4.0.8

我的宝贝:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.8'

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
gem 'json', github: 'flori/json', branch: 'v1.8'
group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

我试图重新安装rails,因为在我的机器上安装了5.0 rails之前.

本地Ruby :

*** LOCAL GEMS ***

autoprefixer-rails (6.6.0)
coffee-rails (4.2.1, 4.0.1)
font-awesome-rails (4.7.0.1)
jquery-atwho-rails (1.3.2)
jquery-rails (4.2.2, 3.1.4)
rails (4.0.8, 4.0.0)
rails-dom-testing (2.0.2)
rails-html-sanitizer (1.0.3)
rails_12factor (0.0.3)
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
sass-rails (5.0.6, 4.0.5)
sprockets-rails (3.2.0, 2.3.3, 2.0.1)

Meybe unistall:ruby和rails将解决这个问题,但我不想这么做.实际上,我想安装两个版本的rails,例如rails 4和rails 5.这种配置可能吗?

推荐答案

在Ruby 2.4中,整数类型是统一的(即FixnumBignum现在是同一个东西:Integer).这导致了相当多的不兼容与现有的Ruby 依赖于阶级的区别.

旧版本的ActiveSupport不喜欢这种统一,并且在try 序列化数据时会对此感到厌烦.因此,您有两种 Select 之一:

  • 您可以将Ruby降级到早于2.4的版本,例如Ruby 2.3.十、
  • 或者你可以把Rails升级到一个更新的版本.最好是Rails 5.x、 在4.2-stable分支中也有一个补丁,它与Rails 4.2.8一起发布,使其成为正式支持Ruby 2.4的Rails 4.2系列的第一个版本.早期的Rails版本与Ruby 2.4不兼容.

Ruby-on-rails相关问答推荐

轨道强参数,怎么允许空参数?

nginx 中的 Rails 7 Active Storage - 图像中途停止加载 net::ERR_HTTP2_PROTOCOL_ERROR 200

是否可以使用 Turbo 帧更新 Rails 表单输入字段值?

如何配置我的 Rails 应用程序(使用 Puma)以通过 HTTPS 提供服务?

Rails 7 共享刺激控制器功能

Rails 7:加载所有刺激控制器

如何获取 Rails 表单构建器将为某个字段生成的 HTML名称属性?

Rails 3.1 assets资源 - 奇怪的开发服务

如何使用 RSpec 和 Devise/CanCan 进行集成测试?

jbuilder vs rails-api/active_model_serializers 用于 Rails 4 中的 JSON 处理

如何使用失败try 次数使设计可锁定

如何从 ActiveRecord 中的每个组中获取最新记录?

如何显示 RSpec 测试生成的 SQL 查询日志(log)?

在 factory_girl 中填充与 children 的关联

在 Rails 中复制模型实例

如何为rails中的number_field添加默认值?

是否可以使用 Rails 迁移重命名索引?

我可以在 Ubuntu 上使用 apt-get 安装 gems 吗?

从任何编码强制字符串为 UTF-8

ruby 方法名称中的变量