修复:在公共贴吧,新建贴吧总提示“提拔名称已存在”的问题

This commit is contained in:
daiao 2016-09-19 13:37:18 +08:00
parent 984b540a63
commit 673b68f2a2
2 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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;