Add author user to related content

This commit is contained in:
Bertocq
2017-12-20 02:05:01 +01:00
parent 4d2d7c1a0a
commit 2688f2a919
3 changed files with 8 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ class RelatedContent < ActiveRecord::Base
acts_as_paranoid column: :hidden_at acts_as_paranoid column: :hidden_at
include ActsAsParanoidAliases include ActsAsParanoidAliases
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
belongs_to :parent_relationable, polymorphic: true, touch: true belongs_to :parent_relationable, polymorphic: true, touch: true
belongs_to :child_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 has_one :opposite_related_content, class_name: 'RelatedContent', foreign_key: :related_content_id

View File

@@ -0,0 +1,5 @@
class AddAuthorToRelatedContent < ActiveRecord::Migration
def change
add_column :related_contents, :author_id, :integer
end
end

View File

@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
@@ -874,6 +874,7 @@ ActiveRecord::Schema.define(version: 20171220002802) do
t.datetime "updated_at" t.datetime "updated_at"
t.integer "related_content_scores_count", default: 0 t.integer "related_content_scores_count", default: 0
t.datetime "hidden_at" t.datetime "hidden_at"
t.integer "author_id"
end end
add_index "related_contents", ["child_relationable_type", "child_relationable_id"], name: "index_related_contents_on_child_relationable", using: :btree add_index "related_contents", ["child_relationable_type", "child_relationable_id"], name: "index_related_contents_on_child_relationable", using: :btree