未初始化的常量Faker :: Date更新到rails 5.1

时间:2017-07-10 21:07:13

标签: ruby-on-rails

当我尝试从rails 5.0更新到5.1时,我有一个正常工作的应用程序。 (我已经从4.2更新到5.0)

它不再起作用,运行如下命令:

rails server

产生错误。我不知道如何解决这个问题,而且我没有找到任何信息,这很奇怪,因为它指向了faker的代码,而不是我的代码。

这是控制台输出

  

/home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:94:in   rescue in block (2 levels) in require': There was an error while trying to load the gem 'faker'. (Bundler::GemRequireError) Gem Load Error is: uninitialized constant Faker::Date Backtrace for gem load error is: /home/gaston/.rvm/gems/ruby-2.3.1/gems/faker-1.8.1/lib/faker/time.rb:2:in &#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/faker-1.8.1/lib/faker/time.rb:1:in   <top (required)>' /home/gaston/.rvm/gems/ruby-2.3.1/gems/faker-1.8.1/lib/faker.rb:214:in 阻止&#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/faker-1.8.1/lib/faker.rb:214:in   each' /home/gaston/.rvm/gems/ruby-2.3.1/gems/faker-1.8.1/lib/faker.rb:214:in &#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:91:in   require' /home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:91:in 阻止(2级)需要&#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in   each' /home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in 阻止了要求&#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in   each' /home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in 需要&#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler.rb:106:in   require' /home/gaston/Workspace/cloud9workspace/projects/time/config/application.rb:7:in &#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/commands/server/server_command.rb:128:in   require' /home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/commands/server/server_command.rb:128:in 阻止执行&#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/commands/server/server_command.rb:125:in   tap' /home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/commands/server/server_command.rb:125:in 执行&#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/thor-0.19.4/lib/thor/command.rb:27:in   run' /home/gaston/.rvm/gems/ruby-2.3.1/gems/thor-0.19.4/lib/thor/invocation.rb:126:in invoke_command&#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/thor-0.19.4/lib/thor.rb:369:in   dispatch' /home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/command/base.rb:63:in 执行&#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/command.rb:44:in   invoke' /home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/commands.rb:16:in &#39;   /家庭/加斯顿/工作区/ cloud9workspace /项目/时间/斌/导轨:9:   require' /home/gaston/Workspace/cloud9workspace/projects/time/bin/rails:9:in &#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in   load' /home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in 呼叫&#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in   call' /home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client.rb:30:in 运行&#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/bin/spring:49:in   <top (required)>' /home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in 负载&#39;   /home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in   <top (required)>' /home/gaston/Workspace/cloud9workspace/projects/time/bin/spring:13:in 需要&#39;   /家庭/加斯顿/工作区/ cloud9workspace /项目/时间/斌/春:13:   <top (required)>' bin/rails:3:in负载&#39; bin / rails:3:<main>' Bundler Error Backtrace: from /home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:90:in 块(2级)in require&#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in   each' from /home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:86:in 阻止了要求&#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in   each' from /home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler/runtime.rb:75:in 需要&#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/bundler-1.13.7/lib/bundler.rb:106:in   require' from /home/gaston/Workspace/cloud9workspace/projects/time/config/application.rb:7:in &#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/commands/server/server_command.rb:128:in   require' from /home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/commands/server/server_command.rb:128:in 阻止执行&#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/commands/server/server_command.rb:125:in   tap' from /home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/commands/server/server_command.rb:125:in 执行&#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/thor-0.19.4/lib/thor/command.rb:27:in   run' from /home/gaston/.rvm/gems/ruby-2.3.1/gems/thor-0.19.4/lib/thor/invocation.rb:126:in invoke_command&#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/thor-0.19.4/lib/thor.rb:369:in   dispatch' from /home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/command/base.rb:63:in 执行&#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/command.rb:44:in   invoke' from /home/gaston/.rvm/gems/ruby-2.3.1/gems/railties-5.1.0/lib/rails/commands.rb:16:in &#39;           来自/ home / gaston / Workspace / cloud9workspace / projects / time / bin / rails:9:in   require' from /home/gaston/Workspace/cloud9workspace/projects/time/bin/rails:9:in &#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in   load' from /home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in 呼叫&#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in   call' from /home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/client.rb:30:in 运行&#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/bin/spring:49:in   <top (required)>' from /home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in 负载&#39;           来自/home/gaston/.rvm/gems/ruby-2.3.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in   <top (required)>' from /home/gaston/Workspace/cloud9workspace/projects/time/bin/spring:13:in 需要&#39;           来自/ home / gaston / Workspace / cloud9workspace / projects / time / bin / spring:13:in   <top (required)>' from bin/rails:3:in负载&#39;           来自bin / rails:3:在`&#39;

这是我的档案: spring.rb

#!/usr/bin/env ruby

# This file loads spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command.

unless defined?(Spring)
  require 'rubygems'
  require 'bundler'

  if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^    (?:  )*spring \((.*?)\)$.*?^$/m))
    Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(Gem.path_separator) }
    gem 'spring', match[1]
    require 'spring/binstub'
  end
end

Faker已包含在gemfile中,我已更新到上一版本。 的Gemfile

gem 'faker', '~> 1.8', '>= 1.8.1'

这是我的application.rb,(前7行) application.rb

require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups) 
...

1 个答案:

答案 0 :(得分:1)

更新时出现问题。我从头开始完成这个过程,现在它可以工作了。它与faker无关。