Hello, I need some help with virtual attributes. This code works fine but how do I use it inside a plugin. The goal is to add this methods to all classes that uses the plugin.
class Article < ActiveRecord::Base
attr_accessor :title, :permalink
def title
if @title
@title
elsif self.page
self.page.title
else
""
end
end
def permalink
if @permalink
@permalink
elsif self.page
self.page.permalink
else
""
end
end
end
Thanks