Rails engines extending functionality

前端 未结 6 763
夕颜
夕颜 2020-12-01 06:50

I have an engine which defines some models and controllers. I want to be able to extend functionality of some models/controllers in my application (eg. adding methods) witho

6条回答
  •  旧时难觅i
    2020-12-01 07:31

    That is true. The controller that is found first will be used.

    So to make it work you might have two options:

    • create a local copy of the controller, and modify the method you need
    • if you have control over the plugin, you could create a Module containing the code and include the code in both controllers, only overriding the method in your local controller. According to me, since there is no multiple inheritance, that is the only way.

    Hope this helps.

提交回复
热议问题