diff --git a/app/controllers/challenges_controller.rb b/app/controllers/challenges_controller.rb index 9ef418cce..a04266bea 100644 --- a/app/controllers/challenges_controller.rb +++ b/app/controllers/challenges_controller.rb @@ -42,13 +42,13 @@ class ChallengesController < ApplicationController end end end - if params[:knowledge][:input].length > 0 + unless params[:knowledge].blank? params[:knowledge][:input].each do |input| ChallengeTag.create(:name => input, :challenge_id => @challenge.id) end end respond_to do |format| - format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun)} + format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: '创建成功!'} end else respond_to do |format| @@ -80,7 +80,10 @@ class ChallengesController < ApplicationController end def destroy - + @challenge.destroy + respond_to do |format| + format.html{redirect_to shixun_challenges_path(@shixun)} + end end def update @@ -104,13 +107,13 @@ class ChallengesController < ApplicationController end end end - if params[:knowledge][:input].length > 0 + unless params[:knowledge].blank? params[:knowledge][:input].each do |input| ChallengeTag.create(:name => input, :challenge_id => @challenge.id) end end end - format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: 'Shixun was successfully created.'} + format.html {redirect_to shixun_challenge_path(@challenge, :shixun_id => @shixun), notice: '更新成功!'} format.json { head :no_content } else format.html { render action: "edit" } diff --git a/app/views/challenges/_form.html.erb b/app/views/challenges/_form.html.erb index 84c9f6e63..44868cc9c 100644 --- a/app/views/challenges/_form.html.erb +++ b/app/views/challenges/_form.html.erb @@ -267,7 +267,7 @@ }else if($("#challenge_score").val().trim()==""){ $("#new_shixun_score").show(); }else{ - $('#new_challenge').submit(); + $('#challenge_shixun_create').submit(); } } @@ -279,7 +279,7 @@ }else if($("#challenge_score").val().trim()==""){ $("#new_shixun_score").show(); }else{ - $('#edit_challenge_48').submit(); + $('#edit_challenge_<%= @challenge.id %>').submit(); } } diff --git a/app/views/challenges/new.html.erb b/app/views/challenges/new.html.erb index bdbd1ddf8..f224de29e 100644 --- a/app/views/challenges/new.html.erb +++ b/app/views/challenges/new.html.erb @@ -11,7 +11,7 @@
diff --git a/app/views/challenges/show.html.erb b/app/views/challenges/show.html.erb index 6ce342ebe..6417ab340 100644 --- a/app/views/challenges/show.html.erb +++ b/app/views/challenges/show.html.erb @@ -9,7 +9,7 @@

第<%= @challenge.position %>关<%= @challenge.subject %>

- +