Question

I am currently delevoping a community using Community Engine, but I need to add some models.

The problem is that I need the helpers methods that are used by CE, but when I try to access the new sections of the site, I get a undefined method (like below)

undefined method `logged_in?' for #<ActionView::Base:0x1048f3748>

The logged_in? method is at vendor/plugins/community_engine/lib/authenticated_system.rb

These method is defined as a helper method like this:

# this is at vendor/plugins/community_engine/lib/authenticated_system.rb
def self.included(base)
  base.send :helper_method, :current_user, :current_user_session, :logged_in?, :admin?, :moderator?
end

How can I make my rails application load all the helpers and the methods declared in lib of my plugins?

Was it helpful?

Solution

You can edit your file vendor/plugins/community_engine/init.rb and add this line to load it:

ActionView::Base.send(:include, MyHelper)

and move you helper in your folder vendor/plugins/community_engine/helpers

module MyHelper
  def my_method_here
    ...
  end
end

Hope this help!

OTHER TIPS

Most sites that I've worked with physically copy the authenticated_system.rb file into #{RAILS_ROOT}/lib and check it in.

That way you can override the methods if you need to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top