On Sat, Apr 28, 2007 at 10:57:28AM +0200, Yaxm Yaxm wrote:
> Jens,
> that works!
> 
> I created this module and put that in a ruby file in the lib folder 
> under my rails app,
> 
> module MyModule
>   module Accessor
>     module ClassMethods
>       def mm_proxy_accessor(object, attributes)
>         attributes.each do |v|
>           define_method( v.to_sym ) do
>             obj = self.send(object)
>             if(obj.nil?)
>               return nil
>             else
>               obj.send v.to_s
>             end
>           end
>         end
>       end
>     end
> 
>     def self.included(base)
>       base.extend(ClassMethods)
>     end
>   end
> end
> 
> Then I include it in my User model.
> 
> but Ruby complains with this error:
> NameError: uninitialized constant User::MyModule

try name that file my_module.rb so Rails has a chance to find it when
you use the module. Or require the file in environment.rb.

Jens

-- 
Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[EMAIL PROTECTED] | www.webit.de
 
Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to