编辑名称检查

This commit is contained in:
lizanle 2015-09-25 15:05:32 +08:00
parent 35dd56d51c
commit befd8d66f6
2 changed files with 2 additions and 5 deletions

View File

@ -296,7 +296,7 @@ class ForumsController < ApplicationController
#检查forum的名字
def check_forum_name
forum_name_exist = Forum.where("name = '#{params[:forum_name]}'").count >= 1 ? true : false
forum_name_exist = Forum.where("name = '#{params[:forum_name]}' and id != #{params[:forum_id]}").count >= 1 ? true : false
render :text => forum_name_exist
end

View File

@ -43,13 +43,10 @@
function check_forum_name(){
check_pass = true;
name = $("textarea[name='forum[name]']").val().trim();
if(name == '<%= @forum.name%>'){
return;
}
if( name != ""){
$.get(
'<%= check_forum_name_forums_path %>',
{"forum_name":name},
{"forum_name":name,"forum_id":<%= @forum.id%>},
function(data){
if( data == 'true'){