Thanks for the tip, I'll add this to the section on overriding models. I'm
not sure I agree with you re: controllers, I've never encountered the
NoMethodErrors you mention, despite overriding tons of controllers.

Maybe with a little more info, we can track down the exact problem.
Thanks!
bruno

On Wed, Nov 5, 2008 at 12:27 AM, bobics <[EMAIL PROTECTED]> wrote:

>
> If you're like me and use CE as a plugin, and want customize CE
> without modifying the original source, there's a pretty simple way
> with the "require_dependency" statement.  This method works for both
> Models and Controllers.  Just create a blank Model or Controller file,
> and call it like this:
>
>   require_dependency "#{RAILS_ROOT}/vendor/plugins/community_engine/
> app/models/user.rb"
>
>   class User < ActiveRecord::Base
>   ...
>   (override only the methods you want)
>   ...
>   end
>
> The reason I use this for Controllers (and not only Models) instead of
> just copying the *_controller.rb file, is because the Controller is
> loaded twice and you'll end up getting a "NoMethodError (undefined
> method `controller_name' for nil:NilClass):" error message on
> production.  This is due to filters being loaded twice when you
> duplicate the controller.  To put it simply, the suggested way of
> overriding a Controller via copying the file WILL give you problems!
> Further reading below.
>
> -bobics
>
>
> http://groups.google.com/group/communityengine/browse_thread/thread/b84154e5228bf9f3
>
> http://rails-engines.org/development/common-issues-when-overloading-code-from-plugins/
>
> http://sites.google.com/a/curbly.com/communityengine/customizing-ce-1/overriding-ce-models
> (Bruno, you may want to update this)
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CommunityEngine" 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/communityengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to