Reputation: 209
I have added the gem 'devise' to my Gemfile. bundle install runs fine, but when I run rails generate devise:install
, I get this error.
The lib/api_constraint.rb
file is a helper file for rspec tests :
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
and my tests lib/api_constraints_spec.rb
ran fine before devise installation:
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
This is the error:
/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>'
Upvotes: 0
Views: 257
Reputation: 3699
Add this to your application.rb
# Custom Auto-Load rb files
config.autoload_paths << Rails.root.join('lib')
config.eager_load_paths << Rails.root.join('lib')
and restart your server
I just cloned and tried, it works
I changed to pg gem and small changes in ruby and rails version, that shouldn't hurt still
Upvotes: 1