forum post votes: add index page.

This commit is contained in:
evazion
2019-10-27 23:05:48 -05:00
parent d617b20b49
commit 0e159960a2
10 changed files with 92 additions and 19 deletions

View File

@@ -8,6 +8,12 @@ class ForumPostVote < ApplicationRecord
scope :by, ->(user_id) {where(creator_id: user_id)}
scope :excluding_user, ->(user_id) {where("creator_id <> ?", user_id)}
def self.search(params)
q = super
q = q.search_attributes(params, :creator, :forum_post_id, :score)
q.apply_default_order(params)
end
def up?
score == 1
end

View File

@@ -91,6 +91,7 @@ class User < ApplicationRecord
has_many :comments, foreign_key: :creator_id
has_many :wiki_page_versions, foreign_key: :updater_id
has_many :feedback, :class_name => "UserFeedback", :dependent => :destroy
has_many :forum_post_votes, dependent: :destroy, foreign_key: :creator_id
has_many :posts, :foreign_key => "uploader_id"
has_many :post_appeals, foreign_key: :creator_id
has_many :post_approvals, :dependent => :destroy