【发布时间】:2019-05-23 08:28:08
【问题描述】:
我正在尝试构建一个 Rails 引擎,并且我有一些我想隔离并仅在 Rails 引擎 Gemfile 中捆绑的 gem。我把这些宝石放在我的Gemfile:
source 'https://rubygems.org'
gemspec
gem "pg", "0.15"
在我的 insurance.gemspec 中:
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "insurance/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |spec|
spec.name = "insurance"
spec.version = Insurance::VERSION
spec.authors = ["Engine Sample"]
spec.email = ["engine@engine.com"]
spec.homepage = "https://github.com/engine/engine_plugin"
spec.summary = "Engine Sample."
spec.description = "Engine Sample."
spec.license = "MIT"
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
if spec.respond_to?(:metadata)
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
end
spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
spec.add_dependency "rails", "~> 5.0.1"
spec.add_development_dependency "route_translator"
end
然后我转到终端上的引擎并运行bundle install,这会在我的引擎文件夹中生成Gemfile.lock。
然后我转到主应用程序并在主应用程序 Gemfile 中添加:
gem 'insurance', path: '/home/Documents/Projects/insurance'
我还在我的引擎文件夹config/routes.rb中创建了一些路由
但是当我运行我的应用程序时,我得到了这个错误
Gem::LoadError - pg is not part of the bundle. Add it to your Gemfile.:
【问题讨论】:
标签: ruby-on-rails rubygems rails-engines