app/controllers/wall_comments_controller.rb
# Used for both wall and blog comments.
Used for both wall and blog comments.
Used for both wall and blog comments .
def create
    @wall_comment = parent.wall_comments.new(params[:wall_comment].merge(:commenter => logged_in_user))
    respond_to do |wants|
      if @wall_comment.save
        wants.js do
          render :update do |page|
            page.insert_html :top, "comments_for_#{dom_id(@parent)}", :partial => 'wall_comments/comment'
            page.visual_effect :highlight, "wall_comment_#{@wall_comment.id}".to_sym
            page.visual_effect :fade, "send-error"
            page << 'jQuery("#comment-body").show();'
            page << 'jQuery("#submit-comment").show();'
            page << 'jQuery("#progress-bar").hide();'
            page << 'jQuery("#comment-body-field").val("留個言吧......");'
            page << 'jQuery("#send-comment-progress").hide();'
            page << 'tb_remove();'
          end
        end
      else
        message = "你無法發送一項空白的留言，且字數不可超過500個字。"
        wants.html do
          flash[:error] = message
          redirect_to wall_comments_url
        end
        wants.js do
          render :update do |page|
            page << 'jQuery("#progress-bar").hide();'
            page << 'jQuery("#send-comment-progress").hide();'
            page << 'jQuery("#comment-body").show();'
            page << 'jQuery("#submit-comment").show();'
            page << 'jQuery("#send-error").show();'
            page << 'tb_remove();'
          end
        end
      end
    end
  end
def create @wall_comment = parent . wall_comments . new ( params [ :wall_comment ] . merge ( :commenter => logged_in_user ) ) respond_to do | wants | if @wall_comment . save wants . js do render :update do | page | page . insert_html :top , "comments_for_#{dom_id(@parent)}" , :partial => 'wall_comments/comment' page . visual_effect :highlight , "wall_comment_#{@wall_comment.id}" . to_sym page . visual_effect :fade , "send-error" page << 'jQuery("#comment-body").show();' page << 'jQuery("#submit-comment").show();' page << 'jQuery("#progress-bar").hide();' page << 'jQuery("#comment-body-field").val("留個言吧......");' page << 'jQuery("#send-comment-progress").hide();' page << 'tb_remove();' end end else message = "你無法發送一項空白的留言，且字數不可超過500個字。" wants . html do flash [ :error ] = message redirect_to wall_comments_url end wants . js do render :update do | page | page << 'jQuery("#progress-bar").hide();' page << 'jQuery("#send-comment-progress").hide();' page << 'jQuery("#comment-body").show();' page << 'jQuery("#submit-comment").show();' page << 'jQuery("#send-error").show();' page << 'tb_remove();' end end end end end
Used for both wall and blog comments.
Used for both wall and blog comments .