Created
August 25, 2010 12:27
-
-
Save coffeeaddict/549399 to your computer and use it in GitHub Desktop.
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 CreateprogramDependencies < ActiveRecord::Migration | |
def self.up | |
create_table :program_dependencies do |t| | |
t.references :dependency, :polymorphic => true | |
t.references :program | |
end | |
end | |
def self.down | |
drop_table :program_dependencies | |
end | |
end | |
class Program < ActiveRecord::Base | |
has_many :program_dependencies | |
has_many :dependencies, :through => :program_dependencies | |
has_many :dependent_program_dependencies, :class_name => "ProgramDependency", :as => :dependency | |
has_many :dependent_programs, :through => :dependent_program_dependencies, :source => :program | |
end | |
class ProgramDependency < ActiveRecord::Base | |
belongs_to :program | |
belongs_to :dependency, :polymorphic => true | |
end | |
class Component < ActiveRecord::Base | |
has_many :program_dependencies, :as => :dependency | |
has_many :dependencies, :through => :program_dependencies | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment