From 2b2498d66abe46f4a5eb088ea84897a01bf6914d Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 27 Dec 2016 16:36:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8=E7=9A=84?= =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ad25b22a9..28e0dbfbd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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)