Loading...

engine-users@lists.rails-engines.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [Engine-users] lib folders and application controllers Tekin Suleyman Tue Feb 27 18:08:15 2007

Why create the model file at all in your app? Couldn't you simply open
the module and override/add your functions?

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Brett
Walker
Sent: 27 February 2007 16:41
To: Discussion of the use of existing Engines
Subject: Re: [Engine-users] lib folders and application controllers


Really?  You can't mix a module from a plugin into your app - you  
have to add it into Rails??  That just seems somehow wrong to me.  I  
thought I could mix a module in anywhere I want - if the main class  
gets reloaded, why won't it's dependencies get reloaded as well?  Is  
that in general, or only with engine plugins?

In any case, I'm running into the same problem with ActiveRbac.   
First run, everything works.  Second run, methods for a model just  
disappear.  In order to create a model that doesn't have to be  
completely copied into the application to be overridden, they created  
a model file that simply includes a mixin module with all the real  
code.  So to override the model in my app I create the model file,  
include the mixin files, and my new functions.

The problem seems to be in one of the models that I don't override.   
First run everything is fine, second run *non* of it's methods are  
found.  It's not just the mixed in ones.  I added a method straight  
in to the model - it wasn't available on the second run.  Here is an  
interesting error I get if I try to do a find on the model:

ArgumentError: A copy of ActiveRbacMixins::UserMixins::Core has been  
removed from the module tree but is still active!

This worked fine in the previous Rails and Engines.  So this is new  
behavior.  What's the best way to fix it?


On Feb 27, 2007, at 9:15 PM, James Adam wrote:

> On 2/27/07, Tekin Suleyman <[EMAIL PROTECTED]> wrote:
>> It appears to me like init.rb is only getting run once during
>> start-up.
>
> This is definitely the case, and is typically why you don't mix 
> modules from plugins into *anything* that will get reloaded. For 
> example, if you're adding methods to all controllers, you should 
> include your module into ActionController::Base, not 
> ApplicationController. The same applies for the rest of your 
> application...
>
> --
> * J *
>   ~
> _______________________________________________
> engine-users mailing list
> [EMAIL PROTECTED]
> http://lists.rails-engines.org/listinfo.cgi/engine-users-rails- 
> engines.org

_______________________________________________
engine-users mailing list
[EMAIL PROTECTED]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.o
rg

_______________________________________________
engine-users mailing list
[EMAIL PROTECTED]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org