How to override the base controller's site_index method?

36 views
Skip to first unread message

Dan Coutu

unread,
May 15, 2014, 7:34:57 PM5/15/14
to communi...@googlegroups.com
My home page is radically different from the default CE home page and so I'd like to be able to override the site_index action to allow for this. Overriding every other controller is pretty easy. Inherit from the the BaseController, use require_from_ce, and you're good to go.

But the base controller can't inherit from itself!

I've tried to create a controller decorator that would let me redefine sites_index but it was studiously ignored.

What's the proper way to override methods that are defined in the base controller?

Dan

Joshua

unread,
May 15, 2014, 8:55:02 PM5/15/14
to communi...@googlegroups.com
I did the following in my case: (may not be the same as in your case)

class Tracking::BaseController < BaseController
  layout 'tracking_base' 
end

I assume you can then override in YourBaseController

then have YourController extend YourBaseController 

e.g., class TrackingController < Tracking::BaseController


food for thoughts. hope this helps.



--
You received this message because you are subscribed to the Google Groups "CommunityEngine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to communityengi...@googlegroups.com.
To post to this group, send email to communi...@googlegroups.com.
Visit this group at http://groups.google.com/group/communityengine.
For more options, visit https://groups.google.com/d/optout.

Bruno Bornsztein

unread,
May 15, 2014, 9:17:48 PM5/15/14
to communi...@googlegroups.com
You can just override BaseController directly:

require_from_ce 'base_controller'

class BaseController < ActiveRecord::Base
  def site_index
    ... your code ...
  end
end


Reply all
Reply to author
Forward
0 new messages