(Mountable) Rails 引擎会继承宝石吗?
Do (Mountable) Rails Engines Inherit Gems?
当我生成 --mountable
Rails 引擎时,它会自动继承所有 parent 应用程序的 gem(和 "assigned" 环境 groups
)根 Gemfile
,child Gemfile
是否允许添加额外的 gem?如果您希望覆盖 parent 的 group
环境,可以在 child 引擎的 Gemfile
中完成吗?
可安装的引擎只是捆绑为 gem 的 Rails 功能的一部分。
Gems 可以有自己的依赖项,这些依赖项在 .gemspec
文件中声明。
Do (Mountable) Rails Engines Inherit Gems?
没有。并不真地。由于 gem 安装在应用程序中,理论上它可以使用应用程序中存在的任何依赖项,但依赖隐式依赖项不是一个好主意,因为它不允许 gem 在隔离。
And should you desire to override the parent's group environments, can this be done in the child engine's Gemfile?
没有。您不应该在 Gemfile 中声明 gems 依赖项,因为 gems 是使用 gem
命令部署的 - 而不是通过 Bundler。
有关 Bundler 核心贡献者之一的更详细解释,请参阅 Clarifying the Roles of the .gemspec and Gemfile。
当我生成 --mountable
Rails 引擎时,它会自动继承所有 parent 应用程序的 gem(和 "assigned" 环境 groups
)根 Gemfile
,child Gemfile
是否允许添加额外的 gem?如果您希望覆盖 parent 的 group
环境,可以在 child 引擎的 Gemfile
中完成吗?
可安装的引擎只是捆绑为 gem 的 Rails 功能的一部分。
Gems 可以有自己的依赖项,这些依赖项在 .gemspec
文件中声明。
Do (Mountable) Rails Engines Inherit Gems?
没有。并不真地。由于 gem 安装在应用程序中,理论上它可以使用应用程序中存在的任何依赖项,但依赖隐式依赖项不是一个好主意,因为它不允许 gem 在隔离。
And should you desire to override the parent's group environments, can this be done in the child engine's Gemfile?
没有。您不应该在 Gemfile 中声明 gems 依赖项,因为 gems 是使用 gem
命令部署的 - 而不是通过 Bundler。
有关 Bundler 核心贡献者之一的更详细解释,请参阅 Clarifying the Roles of the .gemspec and Gemfile。