From 2688f2a91988bf09d1df4a4629c60e59afe06b9f Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 20 Dec 2017 02:05:01 +0100 Subject: [PATCH] Add author user to related content --- app/models/related_content.rb | 1 + db/migrate/20171220010000_add_author_to_related_content.rb | 5 +++++ db/schema.rb | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20171220010000_add_author_to_related_content.rb diff --git a/app/models/related_content.rb b/app/models/related_content.rb index a170c7dca..3ca72d05d 100644 --- a/app/models/related_content.rb +++ b/app/models/related_content.rb @@ -5,6 +5,7 @@ class RelatedContent < ActiveRecord::Base acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases + belongs_to :author, class_name: 'User', foreign_key: 'author_id' belongs_to :parent_relationable, polymorphic: true, touch: true belongs_to :child_relationable, polymorphic: true, touch: true has_one :opposite_related_content, class_name: 'RelatedContent', foreign_key: :related_content_id diff --git a/db/migrate/20171220010000_add_author_to_related_content.rb b/db/migrate/20171220010000_add_author_to_related_content.rb new file mode 100644 index 000000000..4ca621845 --- /dev/null +++ b/db/migrate/20171220010000_add_author_to_related_content.rb @@ -0,0 +1,5 @@ +class AddAuthorToRelatedContent < ActiveRecord::Migration + def change + add_column :related_contents, :author_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index bc1c9c547..9f45b8f3a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171220002802) do +ActiveRecord::Schema.define(version: 20171220010000) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -874,6 +874,7 @@ ActiveRecord::Schema.define(version: 20171220002802) do t.datetime "updated_at" t.integer "related_content_scores_count", default: 0 t.datetime "hidden_at" + t.integer "author_id" end add_index "related_contents", ["child_relationable_type", "child_relationable_id"], name: "index_related_contents_on_child_relationable", using: :btree