每当我尝试在我的 Rails 项目上运行迁移时,我都会得到
ArgumentError: comparison of String with 0.0 failed
。
更奇怪的是它发生在
config/environment.rb
# Initialize the Rails application.
Rails.application.initialize!
我的测试似乎通过了,所以我真的不知道为什么会这样。
我的环境也像这样为 docker 设置:
FROM ruby:2.7.6
RUN apt update
RUN apt install -y nodejs
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN git config --global url."https://gitclone.com/github.com/".insteadOf https://github.com/
# Add Gemfile and Gemfile.lock first for caching
COPY Gemfile /app/
COPY Gemfile.lock /app/
WORKDIR /app
RUN gem install bundler:2.4.7
RUN bundle install --path vendor/bundle --without development test --jobs 4 --retry 3
COPY config/database.yml.example /app/config/database.yml
COPY . /app
RUN RAILS_ENV=production SECRET_KEY_BASE=production_test_key bundle exec rake assets:precompile --trace
# Application port
EXPOSE 3000
ENTRYPOINT ./entrypoint.sh
/app/vendor/bundle/ruby/2.7.0/gems/sentry-rails-5.5.0/lib/sentry/rails/railtie.rb:118:in `activate_tracing'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/railtie.rb:190:in `public_send'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/railtie.rb:190:in `method_missing'
/app/vendor/bundle/ruby/2.7.0/gems/sentry-rails-5.5.0/lib/sentry/rails/railtie.rb:48:in `block in <class:Railtie>'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:51:in `each'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/application/finisher.rb:75:in `block in <module:Finisher>'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
/app/config/environment.rb:5:in `<top (required)>'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/app/vendor/bundle/ruby/2.7.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/app/vendor/bundle/ruby/2.7.0/gems/sentry-ruby-5.5.0/lib/sentry/rake.rb:24:in `execute'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/command.rb:48:in `invoke'
/app/vendor/bundle/ruby/2.7.0/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'