Skip to content

Instantly share code, notes, and snippets.

@ornerymoose
Last active December 1, 2017 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ornerymoose/abb43dad682535d8a1a558475896abbf to your computer and use it in GitHub Desktop.
Save ornerymoose/abb43dad682535d8a1a558475896abbf to your computer and use it in GitHub Desktop.
I need the association model (relationship.rb) to be separate from child and outage, bc child and outage will connect to two separate remote SQL Server databases that will just read data. Where the relationship model will make the association: child belongs_to outage, outage has_many children
class Child < ApplicationRecord
end
class Outage < ApplicationRecord
has_many :relationships
has_many :children, through: :relationships
end
class Relationship < ApplicationRecord
belongs_to :outage, optional: true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment