Note that there are some explanatory texts on larger screens.

plurals
  1. POVote goes through but getting 500 status in response
    text
    copied!<p>I'm using acts_as_votable gem.</p> <p>Here's the log when I do a vote:</p> <pre><code>Started PUT "/stories/11/vote" for 127.0.0.1 at 2013-10-09 15:50:58 +0800 Processing by StoriesController#vote as JSON Parameters: {"id"=&gt;"11"} Story Load (0.6ms) SELECT "stories".* FROM "stories" WHERE "stories"."id" = $1 LIMIT 1 [["id", "11"]] User Load (1.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 14 ORDER BY "users"."id" ASC LIMIT 1 Persona Load (0.4ms) SELECT "personas".* FROM "personas" WHERE "personas"."id" = $1 LIMIT 1 [["id", 15]] (0.4ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = $1 AND "votes"."votable_type" = $2 AND "votes"."voter_id" = 15 AND "votes"."vote_scope" IS NULL AND "votes"."voter_type" = 'Persona' [["votable_id", 11], ["votable_type", "Story"]] ActsAsVotable::Vote Load (3.4ms) SELECT "votes".* FROM "votes" WHERE "votes"."votable_id" = $1 AND "votes"."votable_type" = $2 AND "votes"."voter_id" = 15 AND "votes"."vote_scope" IS NULL AND "votes"."voter_type" = 'Persona' ORDER BY "votes"."id" ASC LIMIT 1 [["votable_id", 11], ["votable_type", "Story"]] (0.2ms) BEGIN (0.2ms) COMMIT (0.3ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = $1 AND "votes"."votable_type" = $2 [["votable_id", 11], ["votable_type", "Story"]] (0.4ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = $1 AND "votes"."votable_type" = $2 AND "votes"."vote_flag" = 't' AND "votes"."vote_scope" IS NULL [["votable_id", 11], ["votable_type", "Story"]] (0.3ms) SELECT COUNT(*) FROM "votes" WHERE "votes"."votable_id" = $1 AND "votes"."votable_type" = $2 AND "votes"."vote_flag" = 'f' AND "votes"."vote_scope" IS NULL [["votable_id", 11], ["votable_type", "Story"]] (0.3ms) BEGIN (0.2ms) COMMIT Completed 500 Internal Server Error in 34ms (Views: 1.6ms | ActiveRecord: 8.0ms) </code></pre> <p>This is my JS:</p> <pre><code>$('.story-vote-up').on("ajax:success", function(evt, data, status, xhr) { console.log(data); }).on("ajax:error", function(evt, data, status, xhr){ console.log(data); }); </code></pre> <p>and the link_to:</p> <pre><code>&lt;%= link_to 'Vote', vote_story_path(story), method: :put, remote: true %&gt; </code></pre> <p>and my controller action:</p> <pre><code> def vote @story = Story.find(params[:id]) respond_to do |format| if @story.liked_by default_persona format.html { redirect_to @story, notice: 'Voted' } format.json { render json: @story, status: :voted, location: @story } else format.html { redirect_to @story, notice: 'Error voting' } format.json { render json: @story.errors, status: :unprocessable_entity } end end end </code></pre> <p>I'm able to get the data in the response I want but why status 500?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload