How to make method defined in a rails engine's application controller automatically available for any other engines which mount it?

StackOverflow https://stackoverflow.com/questions/20872859

Domanda

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. Engine B mounts engine A and engine B's model or controller will call logger method in engine A for logging. Is there a way logger method in engine A could be called by engine B without using include or require? Basically we want logger method in engine A to be automatically available for any other engines which mount it.

È stato utile?

Soluzione

In your engine's application controllers, inherit from parent application controller:

module EngineA
  class ApplicationController < ::ApplicationController
  ..
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top