我想通過在Rails應用程序中重新打開它們來擴展引擎中的模型和控制器。問題是它們在應用程序啓動時未加載。我知道有一些解決方案,如Rails engines extending functionality和how to override rails 3 engine models and controllers in the main application?,但我懷疑這是由於軌道的加載順序,應該有一些整潔的解決方案。從Rails 3.x中重新打開模型和控制器應用程序
然後,我遇到這種解決方案:
config.railties_order = [Blog::Engine, :main_app, :all]
然而,模型和控制器在發動機加載,而不是在軌道的人。 想知道是否有人做過這項工作嗎?
這裏。一個乾淨的解決方案[使用顧慮] [1]。 [1]:http://stackoverflow.com/questions/11675951/testing-model-extensions-for-engines – 2012-07-26 18:43:47