Forum: Ruby on Rails Models, mixins, and acts_as

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Joe C. (Guest)
on 2009-05-23 22:10
(Received via mailing list)
I'm having a little trouble with a mixin.  Here is the long and short, I
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
can just mixin the module for the models where I need it.  Here's the
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_object_name
>       self.to_s.downcase.pluralize
>     end
>     def export_column_names(columns_to_exclude=nil)
>        self.column_names
>     end
>   }
>  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
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
method name for "export_column_names".

Anyone have any ideas how to get around this?
This topic is locked and can not be replied to.