在 Rake 任务中从 Gem 加载文件
使用 Bundler、Rails 3.1.0 和 RVM-gemsets 我想从定义的 Gem 加载文件。
Gem.datadir(gem_name)
似乎是正确的候选者,但似乎不适用于 RVM-gemsets。
添加: 在我的具体情况下,我想加载 YML 文件。显然,Rails 3 能够使用 gem 中的路径和文件扩展 config.i18n.load_path,就好像它们位于我的应用程序的根目录中一样。他们如何实现这种行为?
Using Bundler, Rails 3.1.0 and RVM-gemsets I want to load files from a defined Gem.
Gem.datadir(gem_name)
seems to be the right candidate but does not seem to work with RVM-gemsets.
Addition:
In my specific case I want to load YML Files. Obviously is Rails 3 able to extend config.i18n.load_path
with paths and files from a gem as if they were lying within my app's root. How to they achieve this behaviour?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您需要在运行
Gem#datadir
之前需要 gem。I believe you need to require the gem before running
Gem#datadir
.