jquery - error saving comment ajax -


i'm using simple_form gem tried doing without gem , still same error. don't think it's syntax, tried in haml , same error.

update:

new fixed issues comment below i'm getting "error saving comment" form comments controller below @ end

i'm following tut http://twocentstudios.com/blog/2012/11/15/simple-ajax-comments-with-rails/

comments/_form.html.erb

<%= simple_form_for comment, :remote => true |f| %>  <%= f.input :body, :input_html => { :rows => "2" }, :label => false %>  <%= f.input :commentable_id, :as => :hidden, :value => comment.commentable_id %>  <%= f.input :commentable_type, :as => :hidden, :value => comment.commentable_type %>  <%= f.button :submit, :class => "btn btn-primary", :disable_with => "submitting…" %> <% end %> 

comments/_comment.html.erb

<div class="comment" id="comment-<%= comment.id %>"> <hr/>  <%= link_to "×", comment_path(comment), :method => :delete, :remote => true, :confirm => "are sure want remove comment?", :disable_with => "×", :class => 'close' %>  <h4>   <%= comment.user.username %>   <small>   <%= comment.updated_at %>   </small> </h4> <p> <%= comment.body %> </p> </div> 

comments/show.html.erb

 <%= @user.username %>    <div class="comments">     <h2>comments</h2> 

edited line: @comment :comment

    <%= render :partial => 'comments/form', :locals => { :comment => @new_comment } %>     <%= render :partial => 'comments/comment', :collection => @comments, :as => :comment %>  </div> 

users/show.html.erb

# ....all other code  <h1>   <%= @user.username %>  </h1>    <h2>comments</h2> 

same edit in line

 <%= render :partial => 'comments/form', :locals => { :comment => @new_comment } %>  <%= render :partial => 'comments/comment', :collection => @comments, :as => :comment %> 

commentscontroller

  def create     @comment_hash = params[:comment]     @obj =   @comment_hash[:commentable_type].constantize.find(@comment_hash[:commentable_id])     # not implemented: check see whether user has permission create comment on object     @comment = comment.build_from(@obj, current_user, @comment_hash[:body])     if @comment.save       render :partial => "comments/comment", :locals => { :comment => @comment }, :layout => false, :status => :created     else       render :js => "alert('error saving comment');"     end   end 

comments.js.coffee

  # comments.js.coffee   jquery ->   # create comment   $(".comment-form")     .on "ajax:beforesend", (evt, xhr, settings) ->       $(this).find('textarea')         .addclass('uneditable-input')         .attr('disabled', 'disabled');     .on "ajax:success", (evt, data, status, xhr) ->       $(this).find('textarea')         .removeclass('uneditable-input')         .removeattr('disabled', 'disabled')         .val('');       $(xhr.responsetext).hide().insertafter($(this)).show('slow')         $(document)     .on "ajax:beforesend", ".comment", ->       $(this).fadeto('fast', 0.5)     .on "ajax:success", ".comment", ->       $(this).hide('fast')     .on "ajax:error", ".comment", ->       $(this).fadeto('fast', 1) 


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -