简体   繁体   English

如何从gem配置Rails 3.1应用程序?

[英]How to configure Rails 3.1 app from a gem?

For example, I want to change rails settings when I require my gem to application. 例如,当我需要将gem应用于应用程序时,我想更改rails设置。

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 请帮我

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 看看我做的宝石: https : //github.com/iain/formalize-rails

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM