chromesetting
daiao 6 years ago
parent 2005886b2f
commit dc4270c0b6

@ -162,7 +162,8 @@ class HacksController < ApplicationController
if params[:come_from] if params[:come_from]
hacks = Hack.select(select_sql).mine(current_user.id) hacks = Hack.select(select_sql).mine(current_user.id)
else else
hacks = Hack.select(select_sql).published.opening # 全部包括已经发布的,和我的未发布的
hacks = Hack.select(select_sql).published.opening.merge(Hack.select(select_sql).unpublish.mine(current_user.id))
end end
# 搜索 # 搜索
if params[:search] if params[:search]

@ -12,6 +12,7 @@ class Hack < ApplicationRecord
belongs_to :user belongs_to :user
scope :published, -> { where(status: 1) } scope :published, -> { where(status: 1) }
scope :unpublish, -> { where(status: 0) }
scope :opening, -> {where(open_or_not: 1)} scope :opening, -> {where(open_or_not: 1)}
scope :mine, -> (author_id){ where(user_id: author_id) } scope :mine, -> (author_id){ where(user_id: author_id) }

Loading…
Cancel
Save