预览在issue和new里报错

This commit is contained in:
yanxd 2014-07-09 14:53:29 +08:00
parent 38b3e86e62
commit 4259f63fbf
1 changed files with 1 additions and 10 deletions

View File

@ -16,11 +16,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class PreviewsController < ApplicationController class PreviewsController < ApplicationController
before_filter :find_project, :find_attachments, :find_contest, except: [:contestnotification] before_filter :find_project, :find_attachments, except: :contestnotification
def issue def issue
@issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank? @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
@issue = @contest.issues.find_by_id(params[:id]) unless params[:id].blank?
if @issue if @issue
@description = params[:issue] && params[:issue][:description] @description = params[:issue] && params[:issue][:description]
if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n") if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
@ -65,12 +64,4 @@ class PreviewsController < ApplicationController
render :partial => 'common/preview' render :partial => 'common/preview'
end end
private
def find_contest
contest_id = (params[:issue] && params[:issue][:contest_id]) || params[:contest_id]
@contest = Contest.find(contest_id)
rescue ActiveRecord::RecordNotFound
render_404
end
end end