Rails. How to extend controller class from plugin without any modification in controller file?

Posted by potapuff on Stack Overflow See other posts from Stack Overflow or by potapuff
Published on 2010-03-24T08:08:28Z Indexed on 2010/03/24 8:13 UTC
Read the original article Hit count: 512

I'm use Rails 2.2.2. Rails manual said, the way to extend controller from plug-in is:

Plugin:

module Plug

def self.included(base)
  base.extend ClassMethods
  base.send :include, InstanceMethods
  base.helper JumpLinksHelper
end

 module InstanceMethods
   def new_controller_metod
     ...
   end
 end
 module ClassMethods
 end
end

app/controller/name_controller.rb

class NameController < ApplicationController
  include Plug
  ...

end

Question: is any way to extend controller from plug-in, without any modification of controller file, if we know controller name.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about ruby-on-rails