Models, mixins, and acts_as

I’m having a little trouble with a mixin. Here is the long and short, I am using a technique I found here:

To be able to mixin class and instance methods in the same module (works great btw). I’m using it to make a quick exporter for my models, where I can just mixin the module for the models where I need it. Here’s the brief version of the code:

Class methods are declared in the “define_class_methods” method

the export function

require ‘mixin_class_methods’

module Exporter

mixin_class_methods { |klass| }

define_class_methods {

def export(division, columns_to_exclude)

def rows_to_export
  # must export someting declared in the division
  # ie division.students


def export_object_name

def export_column_names(columns_to_exclude=nil)


} end

class Course < ActiveRecord::Base include Exporter

acts_as_csv_exportable :default, self.export_column_names end

When I have it setup like this, it runs as expected. However, I want to DRY things up and move all the export functionality into the module. If I comment out the “acts_as_csv_exportable :default, self.export_column_names” line and move it to the mixin I get an undefined method name for “export_column_names”.

Anyone have any ideas how to get around this?