首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过余烬-cli- Rails进入rails引擎的Ember引擎

通过余烬-cli- Rails进入rails引擎的Ember引擎
EN

Stack Overflow用户
提问于 2016-12-15 13:37:26
回答 1查看 203关注 0票数 2

我们有一个高度模块化的rails5应用程序,它被分割在rails引擎上,而不是服务器存储库,并集成成红宝石。

现在我们想通过使用EmberJS来介绍ember-cli-rails。主rails应用程序在frontend目录中包含主ember应用程序,而每个rails引擎在frontend目录中包含一个ember引擎(通过ember-engine)。

如何将模块的剩馀引擎安装到主ember引擎中?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-16 08:51:19

由于到目前为止我还没有找到其他解决方案,所以我创建了一个初始化器,它将所有rails引擎的fact引擎目录符号链接到消费rails应用程序中的ember引擎的node_modules中:

代码语言:javascript
复制
# Get the node_modules dir
nm_dir = Rails.root.join('frontend', 'node_modules')

# Delete existing symlinks
Dir.new(nm_dir.to_s).each { |entry| FileUtils.rm_rf(entry) if entry =~ /^.+\-frontend$/ }

# MODULES contains an array of the rails engine gem names
MODULES.each do |module_name|
  # Each module has a Manifest class, load that
  manifest = load_manifest(module_name)

  # Get the path to the frontend dir of the rails engine
  source = Pathname.new(manifest.method(:setup).source_location[0].split('/lib/')[0]).join('frontend').to_s

  # Symlink destination
  destination = nm_dir.join("#{module_name}-frontend").to_s

  # Symlink it
  FileUtils.symlink source, destination, force: true
end

这种方法可能不太干净,但似乎奏效了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41165548

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档