From 673b68f2a28148480139d3ae8af139a6d5ec0162 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 19 Sep 2016 13:37:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E5=9C=A8=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E8=B4=B4=E5=90=A7=EF=BC=8C=E6=96=B0=E5=BB=BA=E8=B4=B4?= =?UTF-8?q?=E5=90=A7=E6=80=BB=E6=8F=90=E7=A4=BA=E2=80=9C=E6=8F=90=E6=8B=94?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=B7=B2=E5=AD=98=E5=9C=A8=E2=80=9D=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/forums_controller.rb | 10 +++++----- app/views/forums/index.html.erb | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 3332f1207..6ebe6b9eb 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -296,12 +296,12 @@ class ForumsController < ApplicationController #检查forum的名字 def check_forum_name - forum_name_exist = true - if params[:forum_id] - forum_name_exist = Forum.where("name = '#{params[:forum_name]}' and id != #{params[:forum_id]}").count >= 1 ? true : false - else + forum_name_exist = false + # if params[:forum_id] + # forum_name_exist = Forum.where("name = '#{params[:forum_name]}' and id != #{params[:forum_id]}").count >= 1 ? true : false + # else forum_name_exist = Forum.where("name = '#{params[:forum_name]}' ").count >= 1 ? true : false - end + # end render :text => forum_name_exist end diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 376ca420a..9b18070a8 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -74,6 +74,7 @@ }); function check_and_submit(doc){ $("#error").html('').hide(); + check_forum_name(); if( $("textarea[name='forum[name]']").val().trim() == "" && $("textarea[name='forum[description]']").val().trim() != "" ){ $("#error").html("名称不能为空").show(); return;