如何从 gem 配置 Rails 3.1 应用程序?
例如,当我需要应用 gem 时,我想更改 Rails 设置。
如果我只是将这一行
Rails.application.config.assets.prefix = '/app/themes/default/assets'
放入我的 gem 中,则不会更改设置。我想我需要在那里使用一些导轨挂钩。
请帮助我伙计们
For example, I want to change rails settings when I require my gem to application.
If I simply put this line
Rails.application.config.assets.prefix = '/app/themes/default/assets'
into my gem, this does not change the settings. I think I need to use some rails hooks there.
Please help me guys
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要配置资产的路径。当放置在正确的位置时,它们应该会自动加载。您需要定义一个“引擎”。看看我制作的 gem:https://github.com/iain/formalize-rails
You shouldn't need to configure the path of the assets. When put in the proper place, they should load automatically. You need to define an "Engine". Have a look at a gem I made: https://github.com/iain/formalize-rails