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

Вопрос

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.

Это было полезно?

Решение

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

module EngineA
  class ApplicationController < ::ApplicationController
  ..
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top