Last active
January 23, 2018 16:42
-
-
Save oferreiro/c76f56d01f31130e03a0d05270692f2d 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 Slide < ApplicationRecord | |
has_one :slide_content, dependent: :destroy | |
has_one :image, through: :slide_content, source: :content, source_type: Image | |
end | |
class SlideContent < ApplicationRecord | |
belongs_to :slide | |
belongs_to :content, polymorphic: true | |
end | |
class Image < ApplicationRecord | |
has_one :slide_content, as: :content | |
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: 20180123152241) do | |
create_table "images", force: :cascade do |t| | |
t.string "name" | |
t.datetime "created_at", null: false | |
t.datetime "updated_at", null: false | |
end | |
create_table "slide_contents", force: :cascade do |t| | |
t.integer "slide_id" | |
t.integer "content_id" | |
t.string "content_type" | |
t.datetime "created_at", null: false | |
t.datetime "updated_at", null: false | |
end | |
add_index "slide_contents", ["slide_id", "content_id", "content_type"], name: "slide_contents_index" | |
create_table "slides", force: :cascade do |t| | |
t.string "title" | |
t.datetime "created_at", null: false | |
t.datetime "updated_at", null: false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment