Ruby on rails 如何在Rails 5项目中安装Desive?

Ruby on rails 如何在Rails 5项目中安装Desive?,ruby-on-rails,ruby-on-rails-5,Ruby On Rails,Ruby On Rails 5,我已将gem“design”添加到我的gem文件中。bundle安装运行良好,但当我运行rails-generate-designe:install时,出现了这个错误 lib/api_constraint.rb文件是rspec测试的辅助文件: class ApiConstraints def initialize(options) @version = options[:version] @default = options[:default] end def ma

我已将gem“design”添加到我的gem文件中。bundle安装运行良好,但当我运行
rails-generate-designe:install
时,出现了这个错误

lib/api_constraint.rb
文件是rspec测试的辅助文件:

class ApiConstraints
  def initialize(options)
    @version = options[:version]
    @default = options[:default]
  end

  def matches?(req)
    @default || req.headers['Accept'].include?("application/vnd.marketplace.v#{@version}")
  end
end
在设计安装之前,我的测试
lib/api\u constraints\u spec.rb
运行良好:

require 'spec_helper'
require './lib/api_constraints'

describe ApiConstraints do
  let(:api_constraints_v1) { ApiConstraints.new(version: 1) }
  let(:api_constraints_v2) { ApiConstraints.new(version: 2, default: true) }

  describe 'matches?' do
    it "returns true when the version matches the 'Accept' header" do
      request = double(host: 'api.marketplace.dev',
                       headers: { 'Accept' => 'application/vnd.marketplace.v1' })
      expect(api_constraints_v1.matches?(request)).to be_truthy
    end

    it "returns the default version when 'default' option is specified" do
      request = double(host: 'api.marketplace.dev')
      expect(api_constraints_v2.matches?(request)).to be_truthy
    end
  end
end
这就是错误:

/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:74:in `block in load_missing_constant': uninitialized constant ApiConstraints (NameError)
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:74:in `rescue in load_missing_constant'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:56:in `load_missing_constant'
    from /home/tac/RubymineProjects/market_place_api/config/routes.rb:4:in `block (2 levels) in <main>'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:948:in `block (2 levels) in namespace'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:879:in `scope'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:948:in `block in namespace'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:1833:in `path_scope'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:947:in `namespace'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:1559:in `namespace'
    from /home/tac/RubymineProjects/market_place_api/config/routes.rb:3:in `block in <main>'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:414:in `draw'
    from /home/tac/RubymineProjects/market_place_api/config/routes.rb:1:in `<main>'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in `block in load_paths'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in `each'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in `load_paths'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:20:in `reload!'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:30:in `block in updater'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active_support/file_update_checker.rb:83:in `execute'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:10:in `execute'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/finisher.rb:130:in `block in <module:Finisher>'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `instance_exec'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `run'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
    from /home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:347:in `each'
    from /home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:347:in `call'
    from /home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
    from /home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
    from /home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:60:in `run_initializers'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application.rb:361:in `initialize!'
    from /home/tac/RubymineProjects/market_place_api/config/environment.rb:5:in `<main>'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:102:in `preload'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
    from /home/tac/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
    from /home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from -e:1:in `<main>'
/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load\u path\u cache/core\u ext/active\u support.rb:74:“加载中的块缺少常量”:未初始化常量ApiConstraints(NameError)
from/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in'without_bootsnap_cache'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load\u path\u cache/core\u ext/active\u support.rb:74:“加载时救援\u丢失\u常量”
from/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load\u path\u cache/core\u ext/active\u support.rb:56:in'load\u missing\u constant'
from/home/tac/RubymineProjects/market\u place\u api/config/routes.rb:4:in'block(2层)in'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action\u dispatch/routing/mapper.rb:948:in`block(2层)in namespace'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/mapper.rb:879:在“范围”中
from/home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action\u dispatch/routing/mapper.rb:948:在“名称空间中的块”中
from/home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action\u dispatch/routing/mapper.rb:1833:在“路径”范围内
from/home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action\u dispatch/routing/mapper.rb:947:“名称空间”中
from/home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action\u dispatch/routing/mapper.rb:1559:在“名称空间”中
from/home/tac/RubymineProjects/market\u place\u api/config/routes.rb:3:in'block in'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action\u dispatch/routing/route\u set.rb:432:in'instance\u exec'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action\u dispatch/routing/route\u set.rb:432:in'eval_block'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/actionpack-5.2.2/lib/action\u dispatch/routing/route\u set.rb:414:in'draw'
from/home/tac/RubymineProjects/market\u place\u api/config/routes.rb:1:in`'
从/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load\u path\u cache/core\u ext/kernel\u require.rb:50:在'load'中
从/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load\u path\u cache/core\u ext/kernel\u require.rb:50:在'load'中
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes\u reloader.rb:41:“加载路径中的块”中
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes\u reloader.rb:41:in“each”
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes\u reloader.rb:41:在“加载路径”中
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes\u reloader.rb:20:in“reload!”
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes\u reloader.rb:30:in“block in updater”
from/home/tac/.rvm/gems/ruby-2.6.0/gems/activesupport-5.2.2/lib/active\u support/file\u update\u checker.rb:83:在“执行”中
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/routes\u reloader.rb:10:in“execute”
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application/finisher.rb:130:in'block in'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in'instance_exec'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in'run'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:61:在“运行中的块初始化器”中
from/home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:228:in`block in tsort_each'
from/home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:350:在每个强连接的组件中的“块(2个级别)”中
from/home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:431:“每个强连接的组件来自”
from/home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:349:in“每个强连接的组件中的块”
from/home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:347:in'each'
from/home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:347:in'call'
from/home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:347:“每个强连接的组件”
from/home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:226:in'tsort_each'
from/home/tac/.rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/tsort.rb:205:in'tsort_each'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/initializable.rb:60:in'run_initializers'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/railties-5.2.2/lib/rails/application.rb:361:in'initialize!'
from/home/tac/RubymineProjects/market\u place\u api/config/environment.rb:5:in`'
来自/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load\u path\u cache/core\u ext/kernel\u require.rb:21:in'require'
来自/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load\u path\u cache/core\u ext/kernel\u require.rb:21:in`block in require_with_bootsnap\u lfi'
从/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load\u path\u cache/load\u features\u index.rb:65:在“寄存器”中
来自/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load\u path\u cache/core\u ext/kernel\u require.rb:20:in`require\u with\u bootsnap\u lfi'
来自/home/tac/.rvm/gems/ruby-2.6.0/gems/bootsnap-1.3.2/lib/bootsnap/load\u path\u cache/core\u ext/kernel\u require.rb:29:in'require'
from/home/tac/.rvm/gems/ruby-2.6.0/gems/spring-2.0.2/lib/spring/application.rb:102:in'preload'
from/home/tac/。
# Custom Auto-Load rb files
config.autoload_paths << Rails.root.join('lib')
config.eager_load_paths << Rails.root.join('lib')