[Radiant] Extending Models in Extensions
John W. Long
ng at johnwlong.com
Wed Mar 28 10:03:24 CDT 2007
Ryan Heneise wrote:
> I've also tried several module mix-ins that haven't worked (i.e.
> packaging a PageExtender module and then including it in Page). For
> example:
>
> module PageExtender
> def self.included(base)
> base.extend(ClassMethods)
> end
> module ClassMethods
> has_many :comments
> end
> end
>
> in ../extensions/comments/lib/page_extender.rb
>
> And then
>
> def activate
> ...
> Page.send :include, PageExtender
> end
>
> ...
>
> Any ideas?
Try:
def activate
Page.class_eval do
has_many :comments
end
end
Or even:
module CommentsPageExtender
def self.included(base)
base.class_eval do
has_many :comments
end
end
end
And:
def activate
...
Page.send :include, CommentsPageExtender
end
--
John Long
http://wiseheartdesign.com
More information about the Radiant
mailing list