Last active
November 13, 2017 20:19
-
-
Save ornerymoose/2ea11de29867684a5c86ca5031c94004 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 Child < ApplicationRecord | |
has_one :outage, through: :relationship | |
has_one :relationship | |
end |
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 Outage < ApplicationRecord | |
has_many :outages, through: :relationships | |
end |
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 Relationship < ApplicationRecord | |
belongs_to :outage | |
belongs_to :child | |
validates_uniqueness_of :child_id, :scope => :outage_id | |
end |
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
ActiveRecord::Schema.define(version: 20171113194934) do | |
create_table "children", force: :cascade do |t| | |
t.string "otn" | |
t.datetime "created_at", null: false | |
t.datetime "updated_at", null: false | |
end | |
create_table "outages", force: :cascade do |t| | |
t.string "htn" | |
t.datetime "created_at", null: false | |
t.datetime "updated_at", null: false | |
end | |
create_table "relationships", force: :cascade do |t| | |
t.integer "outage_id" | |
t.datetime "created_at", null: false | |
t.datetime "updated_at", null: false | |
t.integer "child_id" | |
t.index ["child_id"], name: "index_relationships_on_child_id" | |
t.index ["outage_id"], name: "index_relationships_on_outage_id" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment