From 1744102a5bfc7303c4b8f1a249f620a770c26070 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 9 Dec 2019 20:43:56 +0800 Subject: [PATCH] 1 --- app/controllers/hacks_controller.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index 2cacc362e..c9e9097f8 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -69,10 +69,8 @@ class HacksController < ApplicationController # 新建 @hack.hack_sets.create!(hack_sets_params) # 更新代码 - if params[:hack_codes][:code] != @hack.code - hack_code_params = hack_code_params.merge(modify_time: Time.now) - end - @hack.hack_codes.first.update_attributes!(hack_code_params) + code_params = params[:hack_codes][:code] != @hack.code ? hack_code_params.merge(modify_time: Time.now) : hack_code_params + @hack.hack_codes.first.update_attributes!(code_params) end render_ok rescue Exception => e