I'd like to extend RefineryCMS's PagesController to use some apotomo widgets in our project.
I could potentially do an "override" of the PagesController, which copies it into my project, but I'm using another engine that extends the PagesController (modifying the show and home methods using a module/monkey patching approach) I'd rather avoid that.
My initial approach was something like this:
in config/application.rb:
config.before_initialize do
require 'pages_controller_extensions'
end
config.to_prepare do
PagesController.send :include, Refspike::Extensions
end
In pages_controller_extensions:
module Refspike
module Extensions
class << PagesController
include Apotomo::Rails::ControllerMethods
has_widgets do |root|
root << widget(:map)
end
end
end
end
Unfortunately this blows up on the line "helper ActionViewMethods" in apotomo's controller_methods. Adding include Apotomo::Rails::ActionViewMethods didn't help.
I presume I'm just getting a basic detail about rails dependency management or maybe ruby open classes wrong. Is there an alternative approach, or something simple I'm overlooking?