Application.rb overload?

Hi,

I have an authentification application with methods such as “logged_in?”
in controllers/application.rb. But when I moved the application.rb from
a real app to an engine, these methods are not known anymore. I call the
method from a controller within the engine. Did I miss anything?

Side note: the login_controller in the engine is called, so the engine
is active in a way.

Patrick

Repost, because I wasn’t subscribed to the mailing list:

I have an authentification application with methods such as “logged_in?”
in controllers/application.rb. But when I moved the application.rb from
a real app to an engine, these methods are not known anymore. I call the
method from a controller within the engine. Did I miss anything?

Side note: the login_controller in the engine is called, so the engine
is active in a way.

Patrick

IIRC, engines cause rails to scan
plugin/app/controller/**/*_controller.rb.

If you are overriding ApplicationController in the plugin, you might
need to go to plugin/lib or somewhere else guaranteed to load.

Just a Guess,
Marc

Hi Marc,

IIRC, engines cause rails to scan
plugin/app/controller/**/*_controller.rb.

Most likely, yes.

If you are overriding ApplicationController in the plugin, you might
need to go to plugin/lib or somewhere else guaranteed to load.

What I do now is copy the code to myplugin.rb and require it from
init.rb. This works fine, although it doesn’t feel ‘right’. But what
counts is that it works as intended so thanks for the hint!

Patrick

The approach I’ve used was to name a library after your engine (e.g.
module
FooEngine in foo_engine.rb in the plugin’s lib directory) then include
it
into your application.rb


Tony A.
ClickCaster, Inc.

It seems wrong to me that you’d even want a file called
“application.rb” in a plugin. If you want methods to be available to
all controllers, you can achieve this by adding the methods to
ActionController::Base via module inclusion.

Having routable controllers in plugins doesn’t mean that everything
under your_plugin/app should get mixed - code mixing is the special
case, and shouldn’t be relied upon too much.