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;