修复我参入的实训数据为空问题

This commit is contained in:
huang 2017-06-21 14:43:31 +08:00
parent 6c8bbeb25d
commit 3efcdfc7dc
1 changed files with 2 additions and 3 deletions

View File

@ -658,11 +658,10 @@ class UsersController < ApplicationController
# 我发布的实训
def shixuns
@type = params[:type]
# 我发布的
if @type == "1"
ids = Shixun.find_by_sql("select id from shixun_members where role=2 and user_id=#{@user.id}")
ids = Shixun.find_by_sql("select shixun_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})")
ids = ids.map{|shixun| shixun.id} unless ids.blank?
ids = ids.map{|shixun| shixun.shixun_id} unless ids.blank?
ids2 = ids2.map{|shixun| shixun.id} unless ids2.blank?
id = ids + ids2
id = id.uniq