Need Help: Deployment Issues with Voting App?


#1

I have an app that allows users to submit words. In development, users
can submit words, which are then voted on. Each user can only vote
once. This works fine in development.

However, when I deploy to my production server, users cannot seem to
vote. They click vote, and nothing happens.

This is killing and I don’t know what could be the problem. My code
for voting is below:

Voting Model

class Vote < ActiveRecord::Base
belongs_to :word, :counter_cache => true
belongs_to :user
validates_uniqueness_of :user_id, :scope => :word_id
end

Voting Controller

class VotesController < ApplicationController
before_filter :login_required

def create
@word = Word.find(params[:word_id])
@word.votes.create(:user => @current_user)

respond_to do |format|
format.html { redirect_to @word }
format.js
end

end

end

#Voting view (create)

page.replace_html ‘vote_score’, “Score: #{@word.reload.votes.size}”
page[:vote_score].visual_effect :highlight, :duration => 2.0
page[:vote_score].visual_effect :pulsate, :duration =>
1.5, :collection => @word.votes.latest

#voting view (edit)

page.replace_html ‘vote_score’, “Score: #{@word.votes.size}”

page[:vote_score].visual_effect :highlight, :duration => 2.0

page[:vote_score].visual_effect :pulsate, :duration => 1.5

I could really use some help. Thanks in advance.


#2

On Tue, Dec 2, 2008 at 4:17 PM, Leximo removed_email_address@domain.invalid wrote:

class VotesController < ApplicationController

Have you checked your production logs?

Robby


Robby R.
Chief Evangelist, Partner

PLANET ARGON, LLC
design // development // hosting


http://www.robbyonrails.com/
aim: planetargon

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4068 [fax]


#3

This is what I get in the production log:

Processing VotesController#create (for 68.55.245.214 at 2008-12-03
10:31:51) [POST]
Session ID:
BAh7CToMY3NyZl9pZCIlYTE4MWY4Y2JhMDY0OGE5MmRhYzNjNjUyMGUwZDhm
ZmI6DnJldHVybl90byIGLzoMdXNlcl9pZGkGIgpmbGFzaElDOidBY3Rpb25D
b250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA–
f46c64b9fe41d30837f158a9e54db829d9bd89ca
Parameters: {“commit”=>“Vote Yes”, “action”=>“create”,
“authenticity_token”=>"d7ce6906d1063ebd157e04d63445aee8f528$
Rendering votes/create
Completed in 0.01197 (83 reqs/sec) | Rendering: 0.00658 (54%) | DB:
0.00068 (5%) | 200 OK [http://sitename.org/words/$

And this is what I get on my development server, where voting works:

Processing VotesController#create (for 127.0.0.1 at 2008-12-03
11:15:25) [POST]
Session ID:
BAh7CDoMdXNlcl9pZGkLOgxjc3JmX2lkIiVkNzU3MTBlNTVkYjc5MTVkN2E1
ZDQ4Y2RjZGViYzU2NSIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxh
c2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA==–06f3bc195feabf51948f37d7e1d3c2b6d0bbc554
Parameters: {“commit”=>“Vote Yes”, “action”=>“create”,
“authenticity_token”=>"9b269950803889f0fbfe230ed983bf102b92$
^[[4;35;1mUser Columns (0.005002)^[[0m ^[[0mSHOW FIELDS FROM
users^[[0m
^[[4;36;1mUser Load (0.000246)^[[0m ^[[0;1mSELECT * FROM users
WHERE (users.id = 6) ^[[0m
^[[4;35;1mWord Columns (0.016931)^[[0m ^[[0mSHOW FIELDS FROM
words^[[0m
^[[4;36;1mWord Load (0.006687)^[[0m ^[[0;1mSELECT * FROM words
WHERE (words.id = 104218) ^[[0m
^[[4;35;1mVote Columns (0.030992)^[[0m ^[[0mSHOW FIELDS FROM
votes^[[0m
^[[4;36;1mSQL (0.001828)^[[0m ^[[0;1mBEGIN^[[0m
^[[4;35;1mSQL (0.031889)^[[0m ^[[0mSELECT user_id FROM votes
WHERE (votes.user_id = 6 AND votes.word_id$
^[[4;36;1mVote Create (1.220428)^[[0m ^[[0;1mINSERT INTO votes
(updated_at, user_id, word_id, created_$ ^[[4;35;1mWord Load (0.002985)^[[0m ^[[0mSELECT * FROMwordsWHERE (words.id= 104218) ^[[0m ^[[4;36;1mWord Update (0.114667)^[[0m ^[[0;1mUPDATEwordsSETvotes_count=votes_count+ 1 WHERE (id=$ ^[[4;35;1mSQL (0.239631)^[[0m ^[[0mCOMMIT^[[0m Rendering votes/create ^[[4;36;1mWord Load (0.033487)^[[0m ^[[0;1mSELECT * FROMwordsWHERE (words.id= 104218) ^[[0m ^[[4;36;1mUser Load (0.000246)^[[0m ^[[0;1mSELECT * FROMusersWHERE (users.id= 6) ^[[0m ^[[4;35;1mWord Columns (0.016931)^[[0m ^[[0mSHOW FIELDS FROMwords^[[0m ^[[4;36;1mWord Load (0.006687)^[[0m ^[[0;1mSELECT * FROMwordsWHERE (words.id= 104218) ^[[0m ^[[4;35;1mVote Columns (0.030992)^[[0m ^[[0mSHOW FIELDS FROMvotes^[[0m ^[[4;36;1mSQL (0.001828)^[[0m ^[[0;1mBEGIN^[[0m ^[[4;35;1mSQL (0.031889)^[[0m ^[[0mSELECTuser_idFROMvotesWHERE (votes.user_id = 6 ANDvotes.word_id$ ^[[4;36;1mVote Create (1.220428)^[[0m ^[[0;1mINSERT INTOvotes(updated_at,user_id,word_id,created_$
^[[4;35;1mWord Load (0.002985)^[[0m ^[[0mSELECT * FROM words
WHERE (words.id = 104218) ^[[0m
^[[4;36;1mWord Update (0.114667)^[[0m ^[[0;1mUPDATE words SET
votes_count = votes_count + 1 WHERE (id =$
^[[4;35;1mSQL (0.239631)^[[0m ^[[0mCOMMIT^[[0m
Rendering votes/create
^[[4;36;1mWord Load (0.033487)^[[0m ^[[0;1mSELECT * FROM words
WHERE (words.id = 104218) ^[[0m
^[[4;35;1mVote Load (0.000605)^[[0m ^[[0mSELECT * FROM votes
WHERE (votes.word_id = 104218) ORDER BY id DES$
Completed in 2.15566 (0 reqs/sec) | Rendering: 0.28268 (13%) | DB:
1.70538 (79%) | 200 OK [http://localhost/words/1$

Taking a look at this, I can see that the votes not being created on
the production server. Maybe something is wrong with MySQL??

Any ideas?


#4

This is what I get in the production log:

Processing VotesController#create (for 68.55.245.214 at 2008-12-03
10:31:51) [POST]
Session ID:
BAh7CToMY3NyZl9pZCIlYTE4MWY4Y2JhMDY0OGE5MmRhYzNjNjUyMGUwZDhm
ZmI6DnJldHVybl90byIGLzoMdXNlcl9pZGkGIgpmbGFzaElDOidBY3Rpb25D
b250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA–
f46c64b9fe41d30837f158a9e54db829d9bd89ca
Parameters: {“commit”=>“Vote Yes”, “action”=>“create”,
“authenticity_token”=>"d7ce6906d1063ebd157e04d63445aee8f528$
Rendering votes/create
Completed in 0.01197 (83 reqs/sec) | Rendering: 0.00658 (54%) | DB:
0.00068 (5%) | 200 OK [http://sitename.org/words/$

And this is what I get on my development server, where voting works:

Processing VotesController#create (for 127.0.0.1 at 2008-12-03
11:15:25) [POST]
Session ID:
BAh7CDoMdXNlcl9pZGkLOgxjc3JmX2lkIiVkNzU3MTBlNTVkYjc5MTVkN2E1
ZDQ4Y2RjZGViYzU2NSIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxh
c2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA==–06f3bc195feabf51948f37d7e1d3c2b6d0bbc554
Parameters: {“commit”=>“Love it”, “action”=>“create”,
“authenticity_token”=>"9b269950803889f0fbfe230ed983bf102b92$
^[[4;35;1mUser Columns (0.005002)^[[0m ^[[0mSHOW FIELDS FROM
users^[[0m
^[[4;36;1mUser Load (0.000246)^[[0m ^[[0;1mSELECT * FROM users
WHERE (users.id = 6) ^[[0m
^[[4;35;1mWord Columns (0.016931)^[[0m ^[[0mSHOW FIELDS FROM
words^[[0m
^[[4;36;1mWord Load (0.006687)^[[0m ^[[0;1mSELECT * FROM words
WHERE (words.id = 104218) ^[[0m
^[[4;35;1mVote Columns (0.030992)^[[0m ^[[0mSHOW FIELDS FROM
votes^[[0m
^[[4;36;1mSQL (0.001828)^[[0m ^[[0;1mBEGIN^[[0m
^[[4;35;1mSQL (0.031889)^[[0m ^[[0mSELECT user_id FROM votes
WHERE (votes.user_id = 6 AND votes.word_id$
^[[4;36;1mVote Create (1.220428)^[[0m ^[[0;1mINSERT INTO votes
(updated_at, user_id, word_id, created_$ ^[[4;35;1mWord Load (0.002985)^[[0m ^[[0mSELECT * FROMwordsWHERE (words.id= 104218) ^[[0m ^[[4;36;1mWord Update (0.114667)^[[0m ^[[0;1mUPDATEwordsSETvotes_count=votes_count+ 1 WHERE (id=$ ^[[4;35;1mSQL (0.239631)^[[0m ^[[0mCOMMIT^[[0m Rendering votes/create ^[[4;36;1mWord Load (0.033487)^[[0m ^[[0;1mSELECT * FROMwordsWHERE (words.id= 104218) ^[[0m ^[[4;36;1mUser Load (0.000246)^[[0m ^[[0;1mSELECT * FROMusersWHERE (users.id= 6) ^[[0m ^[[4;35;1mWord Columns (0.016931)^[[0m ^[[0mSHOW FIELDS FROMwords^[[0m ^[[4;36;1mWord Load (0.006687)^[[0m ^[[0;1mSELECT * FROMwordsWHERE (words.id= 104218) ^[[0m ^[[4;35;1mVote Columns (0.030992)^[[0m ^[[0mSHOW FIELDS FROMvotes^[[0m ^[[4;36;1mSQL (0.001828)^[[0m ^[[0;1mBEGIN^[[0m ^[[4;35;1mSQL (0.031889)^[[0m ^[[0mSELECTuser_idFROMvotesWHERE (votes.user_id = 6 ANDvotes.word_id$ ^[[4;36;1mVote Create (1.220428)^[[0m ^[[0;1mINSERT INTOvotes(updated_at,user_id,word_id,created_$
^[[4;35;1mWord Load (0.002985)^[[0m ^[[0mSELECT * FROM words
WHERE (words.id = 104218) ^[[0m
^[[4;36;1mWord Update (0.114667)^[[0m ^[[0;1mUPDATE words SET
votes_count = votes_count + 1 WHERE (id =$
^[[4;35;1mSQL (0.239631)^[[0m ^[[0mCOMMIT^[[0m
Rendering votes/create
^[[4;36;1mWord Load (0.033487)^[[0m ^[[0;1mSELECT * FROM words
WHERE (words.id = 104218) ^[[0m
^[[4;35;1mVote Load (0.000605)^[[0m ^[[0mSELECT * FROM votes
WHERE (votes.word_id = 104218) ORDER BY id DES$
Completed in 2.15566 (0 reqs/sec) | Rendering: 0.28268 (13%) | DB:
1.70538 (79%) | 200 OK [http://localhost/words/1$

Taking a look at this, I can see that the votes not being created on
the production server. Maybe something is wrong with MySQL??

Any ideas?


#5

Leximo wrote:

Taking a look at this, I can see that the votes not being created on
the production server. Maybe something is wrong with MySQL??

It’s normal not to see database activity in production log.

Perhaps you should use create! rather than create to ensure
that there are no problems inserting the vote.


Rails Wheels - Find Plugins, List & Sell Plugins -
http://railswheels.com