Versions
- Ruby: 2.3.3
- Ruby:2.3.3
- Bundler: 1.14.6
- Bundler:1.14.6
- Rails: 5.0.2
- Rails:5.0.2
- acts-as-taggable-on: 4.0.0
- act-as-taggable-on:4.0.0
- Rspec: 3.5.4
- Rspec:3.5.4
Gemfile
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
gem 'acts-as-taggable-on', '~> 4.0'
group :development, :test do
gem 'rspec-rails', '~> 3.5'
end
Logic
lib/acts_as_taggable_on/generic_parser.rb
LIB / acts_as_taggable_on / generic_parser.rb
class MyParser < ActsAsTaggableOn::GenericParser
def parse
ActsAsTaggableOn::TagList.new.tap do |tag_list|
tag_list.add @tag_list.split(',').map(&:strip).reject(&:empty?)
end
end
end
Exception
When running rpsec
, got these errors:
运行rpsec时,遇到以下错误:
/Users/user/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/runtime.rb:94:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'acts-as-taggable-on'. (Bundler::GemRequireError)
Gem Load Error is: uninitialized constant ActsAsTaggableOn::GenericParser
How to fix it?
怎么解决?
1 个解决方案
#1
1
Your file name is incorrect, you have
您的文件名不正确
lib/acts_as_taggable_on/generic_parser.rb
If the class is MyParser Rails need to map to that class via the name of the file which should be my_parser.rb and thus it should be
如果该类是MyParser Rails需要通过文件的名称映射到该类,该文件应该是my_parser.rb,因此它应该是
lib/acts_as_taggable_on/my_parser.rb
#1
1
Your file name is incorrect, you have
您的文件名不正确
lib/acts_as_taggable_on/generic_parser.rb
If the class is MyParser Rails need to map to that class via the name of the file which should be my_parser.rb and thus it should be
如果该类是MyParser Rails需要通过文件的名称映射到该类,该文件应该是my_parser.rb,因此它应该是
lib/acts_as_taggable_on/my_parser.rb