0
나는 나의 좋아하는 것을 위해 유사하게 보이는 activerecord 클래스들을 가지고있다!다형성 activerecord 클래스를 사용하는 방법은 무엇입니까?
기본 클래스를 확장하여 메소드를 늘리거나 레일을 혼동시킬 수 있습니까?
어쩌면 다른 사람들과 공유 할 수 있나요?
아니요 - 계속 진행하는 가장 좋은 방법은 무엇입니까?
많은 감사를)
class Stage < ActiveRecord::Base
acts_as_taggable
has_many :services, :as => :serviceable
belongs_to :event
belongs_to :user
after_save :tag!
def t(s)
self.tag_list.add s
self.event.tag_list.add s
end
# injected to after_save -> http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html
def tag!
s = self
if s.id > 0 then s.t "id-greater-than-0" end
if s.id > 0 then s.t "some-stage-specific-stuff" end
self.tag_list
end
end
class Sound < ActiveRecord::Base
acts_as_taggable
has_many :services, :as => :serviceable
belongs_to :event
belongs_to :user
after_save :tag!
def t(s)
self.tag_list.add s
self.event.tag_list.add s
end
# injected to after_save -> http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html
def tag!
s = self
if s.id > 0 then s.t "some-sound-specific-stuff" end
self.tag_list
end
end