Make it clear: you have a method defined in the module and you want this method to be used in the instance method.
class MyController < ApplicationController include Select
I will change my module a bit. Instead of extend , include used. extend is for adding class methods and include for adding instance methods:
module Select def self.included(base) base.class_eval do include InstanceMethods end end module InstanceMethods def select_for(object_name, options={})
This will give you an instance method. If you need instance and class methods, you simply add the ClassMethods module and use extend instead of include :
module Select def self.included(base) base.class_eval do include InstanceMethods extend ClassMethods end end module InstanceMethods def select_for(object_name, options={})
It is clear? In your example, you defined the module as Select , but included Selector in your controller ... I just used Select in my code.
mixonic
source share