From 38c721609712cea1ed681b2f0ff0201f42390f4e Mon Sep 17 00:00:00 2001 From: wanglinchun Date: Sat, 10 May 2014 10:15:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E5=8F=82=E8=B5=9B=E4=BD=9C=E5=93=81=E5=90=8E=E5=BC=B9=E5=87=BA?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E6=88=90=E5=8A=9F=E7=9A=84=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 4 ++-- app/controllers/softapplications_controller.rb | 6 ++++-- app/views/softapplications/create.js.erb | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 app/views/softapplications/create.js.erb diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 85fa7244a..8968f0bf4 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -376,10 +376,10 @@ class ContestsController < ApplicationController contest_message = params[:contest_for_save][:contest_message] if ContestingSoftapplication.where("softapplication_id = ? and contest_id = ?", softapplication.id, @contest.id).size == 0 if ContestingSoftapplication.create_softapplication_contesting(@contest.id, softapplication.id, contest_message) - flash.now[:notice] = l(:label_release_add_contest_succeed) + flash[:notice] = l(:label_release_add_contest_succeed) end else - flash.now[:error] = l(:label_add_contest_succeed_fail) + flash[:error] = l(:label_add_contest_succeed_fail) end @contesting_softapplication = paginateHelper @contest.contesting_softapplications diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index 3aba819e0..9ede52489 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -106,11 +106,13 @@ class SoftapplicationsController < ApplicationController @softapplication.save_attachments(params[:attachments]) respond_to do |format| if @softapplication.save + format.js format.html { redirect_to @softapplication, notice: 'Softapplication was successfully created.' } - format.json { render json: @softapplication, status: :created, location: @softapplication } + # format.json { render json: @softapplication, status: :created, location: @softapplication } else + format.js { render status: 406 } format.html { render action: "new" } - format.json { render json: @softapplication.errors, status: :unprocessable_entity } + # format.json { render json: @softapplication.errors, status: :unprocessable_entity } end end end diff --git a/app/views/softapplications/create.js.erb b/app/views/softapplications/create.js.erb new file mode 100644 index 000000000..7f4ac2284 --- /dev/null +++ b/app/views/softapplications/create.js.erb @@ -0,0 +1 @@ +alert('新建参赛作品成功!');