From 3b36a5e8bb8aed8d2b910da2708e256f014cc1ca Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 2 Jan 2020 11:37:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hacks_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/controllers/hacks_controller.rb b/app/controllers/hacks_controller.rb index 739f37a6f..84c24a6d9 100644 --- a/app/controllers/hacks_controller.rb +++ b/app/controllers/hacks_controller.rb @@ -61,6 +61,8 @@ class HacksController < ApplicationController hack_codes = hack.hack_codes.new(hack_code_params) hack_codes.modify_time = Time.now hack_codes.save! + new_item_params = item_params.merge({container: hack_codes, item_type: 'PROGRAM'}) + ItemBank.create!(new_item_params) end render_ok({identifier: hack.identifier}) rescue Exception => e @@ -189,6 +191,10 @@ class HacksController < ApplicationController params.require(:hack).permit(:name, :description, :difficult, :category, :open_or_not, :time_limit, :score, :sub_discipline_id) end + def item_params + params.require(:hack).permit(:name, :difficult, :sub_discipline_id) + end + def hack_sets_params params.permit(hack_sets: [:input, :output, :position])[:hack_sets] end