Last active
August 29, 2015 14:05
-
-
Save josiasds/897c20342813a7281f66 to your computer and use it in GitHub Desktop.
Polymorphic Timelines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Campaign < ActiveRecord::Base | |
has_many :timelines, :through => :assignment | |
end | |
class Timeline < ActiveRecord::Base | |
self.abstract_class = true | |
end | |
class Assignment < ActiveRecord::Base | |
belongs_to :campaign | |
belongs_to :timeline, :polymorphic => true | |
end | |
class FbAuth < Timeline | |
has_many :campaigns, :through => :assignment, :as => :timeline | |
end | |
class TwAuth < Timeline | |
has_many :campaigns, :through => :assignment, :as => :timeline | |
end | |
class FbPage < Timeline | |
has_many :campaigns, :through => :assignment, :as => :timeline | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment