javascript - Ruby On Rails Ajax Submit submitting twice -
so decided make blog in ror , got comments submit , not when went "update" submit method allow page not refreshed when comment posted (ajax) whenever go post comment on pages reason loops send comment submit , 2 comments same message appearing @ same time.
<h2>comments</h2> <div id="comments"> <%= render :partial => @post.comments %> </div> <%= form_for [@post, comment.new], :remote => true |f| %> <p> <%= f.label :body, "new comment" %><br/> <%= f.text_area :body %> </p> <p><%= f.submit "add comment", disable_with: "adding comment..." %></p> <% end %>
that show point, can see tried see if disabling button disable_with has not.
and below comment_controller
class commentscontroller < applicationcontroller def create @post = post.find(params[:post_id]) @comment = @post.comments.create!(comment_params) respond_to |format| format.html { redirect_to @post } format.js end end private def comment_params params.require(:comment).permit(:commenter, :body, :post_id) end end
thanks advice.
looks have 2 sets of precompiled assets running locally:.
try on machine:
rails_env=development bundle exec rake assets:clobber rails_env=development bundle exec rake assets:precompile
happens me time.
Comments
Post a Comment