Why is Rails app sending two Ajax requests instead of one, only when using Firefox and on my local server? -


i'm learning rails development , building reddit-like app voting on comments , posts learn. have ajax-ified voting, , on local machine when vote post/comment or down sends 2 requests , creates 2 votes on either object. these votes viewable in votes table.

this occurs in firefox (not chrome or ie), , occurs on local machine (it's fine in heroku). verified firebug sending 2 requests, can't figure out why. don't believe asset pipeline causing trouble because there isn't in there.

this started once modified voting behavior reloading page on each vote using ajax display vote totals. note user can vote many times he/she wants right now

my code on github here: https://github.com/hellomcfly/tl_postit2

my app on heroku here: http://fathomless-waters-1981.herokuapp.com

i don't know code help, here in postscontroller:

def vote     @vote = vote.create(voteable: @post, user: current_user, vote: params[:vote])       respond_to |format|       format.html         if @vote.vote == false           flash[:alert] = "downvote tallied!"           redirect_to :back         else           flash[:success] = "upvote tallied!"           redirect_to :back         end       end       format.js     end        end 

and here relevant code in posts#index template:

net votes: <span id="post_<%=post.id%>_votes"><%= post.net_votes %></span> <ul>     <li><%= link_to "vote up", vote_post_path(post, vote: true), method: 'post', remote: true %></li>     <li><%= link_to "vote down", vote_post_path(post, vote: false), method: 'post', remote: true %></li> </ul>    

and here vote.js.erb code:

$("#post_<%= @post.id %>_votes").html(<%= @post.net_votes %>); 

thanks help.

i ran problem in similar circumstances, related having precompiled assets in public/assets. causing application.js loaded twice.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -