From b05bd236cdf9f9ff7217172cee95a02edf022eec Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 9 Jun 2017 21:59:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f2a395960..33487ddde 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -665,10 +665,14 @@ class UsersController < ApplicationController @shixuns = paginateHelper @shixuns, @limit # 我参入的 + id = [] ids = Shixun.find_by_sql("select id from shixun_members where role=2 and user_id=#{@user.id}") ids2 = Shixun.find_by_sql("select id from shixuns where id in (select shixun_id from myshixuns where user_id = #{@user.id})") - - @join_shixuns = Shixun.find_by_sql("select * from shixuns where id in (select shixun_id from myshixuns where user_id = #{@user.id})") + ids = ids.map{|shixun| shixun.id} unless ids.blank? + ids2 = ids2.map{|shixun| shixun.id} unless ids2.blank? + id = ids + ids2 + id = id.uniq + @join_shixuns = Shixun.where(:shixun_id => id) # @join_shixuns_count = @join_shixuns.count # @join_shixuns_pages = Paginator.new @join_shixuns_count, @limit, params['page'] || 1 # @join_shixuns_offset ||= @join_shixuns_pages.offset