[英]How to make method defined in a rails engine's application controller automatically available for any other engines which mount it?
Rails 3.2 engine A
is a logger engine and there is a logger
method (create an entry in log table) defined in its application controller
. Rails 3.2 engine A
是一个记录器引擎,并且在其application controller
定义了一个logger
方法(在日志表中创建条目)。 Engine B
mounts engine A
and engine B's
model
or controller
will call logger method in engine A for logging. Engine B
安装了engine A
, engine B's
model
或controller
将调用引擎A中的记录器方法进行记录。 Is there a way logger
method in engine A
could be called by engine B
without using include
or require
? engine B
是否可以在不使用include
或require
情况下调用engine A
logger
方法? Basically we want logger
method in engine A
to be automatically available for any other engines which mount it. 基本上,我们希望engine A
logger
方法可自动用于安装它的任何其他引擎。
In your engine's application controllers, inherit from parent application controller: 在引擎的应用程序控制器中,从父应用程序控制器继承:
module EngineA
class ApplicationController < ::ApplicationController
..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.