From 42f0c490936f6e21c206d9283371f1991ba1f1b4 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 25 Jul 2014 11:08:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=89=93=E5=8C=85=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA=E9=A1=B5=E6=97=A0?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 9 +++++++-- app/controllers/zipdown_controller.rb | 8 +++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e6efca1e8..110974b77 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -482,14 +482,19 @@ class ApplicationController < ActionController::Base # Renders an error response def render_error(arg) arg = {:message => arg} unless arg.is_a?(Hash) - @message = arg[:message] + @lay = arg[:layout] @message = l(@message) if @message.is_a?(Symbol) @status = arg[:status] || 500 respond_to do |format| format.html { - render :template => 'common/error', :layout => use_layout, :status => @status + if @lay + render :template => 'common/error', :layout => @lay,:status => @status + else + render :template => 'common/error', :layout => use_layout, :status => @status + end + } format.any { head @status } end diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 16e6ea870..a5506be93 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -1,4 +1,5 @@ class ZipdownController < ApplicationController + #查找项目(课程) before_filter :find_project_by_bid_id, :only => [:assort] #检查权限 @@ -43,14 +44,15 @@ class ZipdownController < ApplicationController zipfile = zip_homework_by_user homework send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if(zipfile) else - render_403 :message => :no_file_dowmload + render_403 :message => :no_file_dowmload ,:layout => "course_base" end else - render_403 :message =>:notice_file_not_found + render_403 :message =>:notice_file_not_found ,:layout => "course_base" end else - render_403 :message => :notice_not_authorized + render_403 :message => :notice_not_authorized ,:layout => "course_base" end + rescue => e render file: 'public/file_not_found.html' end