Friday, October 15, 2010

[Rails] Re: How Extend AR Instance Methods?

On Friday 15 October 2010, Greg Willits wrote:
> I'm trying to extend AR with a method which needs to be available to
> both the class and the instance.
>
> I've tried a gajillion permutations based on examples. I can get the
> method added to the Class, but not to instances.

module MyMethods
def self.included(base)
base.extend(self)
end

def shared_method
"Hello?"
end
end

Michael

--
Michael Schuerig
mailto:michael@schuerig.de
http://www.schuerig.de/michael/

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate