ruby-on-rails - 如何修复“警告:常量 ::Fixnum 已弃用”错误
问题描述
当我尝试从 RubyMine IDE 运行我的 rails 服务器时,我收到错误消息:
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
ExitingTraceback
我目前正在使用 Rails 4.2.7.1 运行 Ruby 2.5.5p157。为了运行 Web 应用程序,我应该怎么做?非常感谢您的帮助!
尝试运行网站时的完整日志:
C:\Ruby25-x64\bin\ruby.exe "C:/Users/Sam/Desktop/Takai/Website/bin/rails" server -b 127.0.0.1 -p 3000 -e development -b 0.0.0.0
=> Booting WEBrick
=> Rails 4.2.7.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Fixnum is deprecated
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/activesupport-4.2.7.1/lib/active_support/core_ext/numeric/conversions.rb:121: warning: constant ::Bignum is deprecated
ExitingTraceback
(most recent call last):
C:/Users/Sam/Desktop/Takai/Website/bin/rails: stack level too deep (SystemStackError)
Process finished with exit code 1
解决方案
您正在使用旧版本的 Rails 和新版本的 Ruby,Rails 想要使用Fixnum
新版本的 Ruby 中不再存在的东西 ( )。
你有两个选择:
- 使用旧版本的 Rails 支持的 Ruby 版本。根据这个列表, Ruby 2.4 应该适合你。
- 将您的 Rails 应用程序更新为支持 Ruby 2.5 的更新版本的 Rails。Rails 5.1 似乎是第一个正式支持 Ruby 2.5 的 Rails 版本
第一个选项可能要容易得多。但我仍然建议更新您的 Rails 版本,因为您的 Rails 版本未维护,不会再获得任何更新或安全性。
推荐阅读
- google-cloud-platform - 谷歌colab上传时间到谷歌驱动器
- php - 使用来自 API 调用的数据验证出生日期
- python - 用 Java 编写 .CSV 文件时遇到问题?
- java - 如何使用 JEP 412 从 Java 17 调用 C 函数:外部函数和内存 API
- javascript - 根据显示的图片更改“喜欢”
- php - 使用枚举在带有 PDO/HTML 的 1 页上创建 2 个表单
- javascript - 使用类的待办事项列表
- ios - XCode13 和 iOS15 和 iPadOS15 上的 swiftUI 表单错误
- python - “无效参数:redirect_uri” Keycloak 设置
- python - 如何从此输入中获取此输出“输出-Mon-Wed-7-19 Thu-11-19 Friday-Sat open 24 hours Sun-closed”