From 8dd6b6ffe418e83dcd345f284fa5333534ef396f Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 18 May 2017 14:50:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=A2=84=E5=A4=87=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E7=8B=AC=E7=AB=8B=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E5=8F=8A=E6=95=B0=E6=8D=AE=E8=AF=BB=E5=8F=96=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 1 + app/controllers/shixuns_controller.rb | 2 +- app/views/games/_game_show.html.erb | 2 +- .../20170518064248_sync_propaedeutics_to_shixuns.rb | 12 ++++++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20170518064248_sync_propaedeutics_to_shixuns.rb diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index a7d4a7c08..b01ff6c14 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -33,6 +33,7 @@ class GamesController < ApplicationController # logger.info("#################%%%%%%#{@game.outputs.first.out_put}") # @games = @myshixun.games.includes(:challenge) @challenges = Challenge.where(:shixun_id => @myshixun.shixun_id) + @shixun = @myshixun.shixun # @games_count = @games.count @game_challenge = @game.challenge @had_done = @game.had_done diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index ac496314e..711ff46e2 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -300,7 +300,7 @@ class ShixunsController < ApplicationController CODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z) def copy_myshixun shixun, gshixun myshixun = Myshixun.new - myshixun.attributes = shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier") + myshixun.attributes = shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier","propaedeutics") myshixun.shixun_id = shixun.id myshixun.user_id = User.current.id myshixun.gpid = gshixun.id diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index 7547a2226..73caee78e 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -38,7 +38,7 @@
- +
diff --git a/db/migrate/20170518064248_sync_propaedeutics_to_shixuns.rb b/db/migrate/20170518064248_sync_propaedeutics_to_shixuns.rb new file mode 100644 index 000000000..f34a762d0 --- /dev/null +++ b/db/migrate/20170518064248_sync_propaedeutics_to_shixuns.rb @@ -0,0 +1,12 @@ +class SyncPropaedeuticsToShixuns < ActiveRecord::Migration + def up + change_column :challenges, :ready_knowledge, :longtext + Shixun.all.each do |shixun| + ready_knowledge = shixun.challenges.first.try(:ready_knowledge) + shixun.update_attribute(:propaedeutics, ready_knowledge) + end + end + + def down + end +end