仮想属性についてサポートが必要です。このコードは正常に機能しますが、プラグイン内でどのように使用しますか。目標は、プラグインを使用するすべてのクラスにこのメソッドを追加することです。
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
ありがとう