Hi Tim

I'm not super experienced with engines, but here's my thoughts:

* Don't put ApplicationController in your engine - I think that should only be 
located in the application itself. What you can do to get your code into the 
app is make Xebec::ApplicationController a subclass of ActionController::Base, 
and then your app's ApplicationController a subclass of 
Xebec::ApplicationController (as you've hinted at the end of your email). This 
means you can avoid reopening the class.

* Also, with that custom superclass, you can include the helpers you want 
there, and they'll be loaded for every controller subclassing from it.

* Don't manually require anything that a Rails app would normally load itself 
(especially anything in app/models, app/controllers and app/helpers). That goes 
for the models, controllers and helpers in your engine as well as what's in the 
Rails app.

Cheers

-- 
Pat

On 03/09/2011, at 11:57 PM, Tim Uckun wrote:

> I decided to create a Rails engine to move a lot of commonly used
> models, helpers, and even gems into a gem I can include in my rails
> apps.  Most things are working OK but I can't seem to make a shared
> ApplicationController which can be re-opened by the app that us using
> the gem.
> 
> I am also running into some issues with re-opening modules for some
> reason so maybe the two issues are related.   For example...
> 
> I add the xebec gem as a dependency to my gem/engine. xebec requires
> that I put "helper Xebec::NavBarHelper" into my ApplicationController
> so I create a file in the engine like this.
> 
> /app/controllers/application_controller
> class ApplicationController < ActionController::Base
>  helper Xebec::NavBarHelper
> end
> 
> 
> When I do this nothing happens the controller code is not being
> called. So I require the file explicitly in my gem but then all the
> helpers in the application_helper of the parent app go away.
> 
> I think one way to solve this problem would be for the parent
> ApplicationController to inherit from this one but I am wondering if
> there a better way to deal with.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby or Rails Oceania" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rails-oceania?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to