课程列表的班级收藏

This commit is contained in:
cxt 2016-12-27 16:36:35 +08:00
parent f1a4cac61c
commit 2b2498d66a
1 changed files with 3 additions and 1 deletions

View File

@ -4067,8 +4067,10 @@ class UsersController < ApplicationController
@contest = Contest.find params[:contest]
member = ContestMember.where("user_id = #{@user.id} and contest_id = #{@contest.id}")
end
unless member.empty?
if !member.empty? && params[:contest]
member.first.update_attribute(:is_collect, member.first.is_collect == false ? 1 : 0)
elsif !member.empty?
member.first.update_attribute(:is_collect, member.first.is_collect == 0 ? 1 : 0)
end
if @project
@projects = @user.favorite_projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10)