Note that there are some explanatory texts on larger screens.

plurals
  1. PORails counter cache is not working on production
    text
    copied!<p>I've got weird problem with counter cache mechanism at Rails 3.1.4 (ruby 1.8.7). When I am running my app on development server everything works great. After switching to production environment comments_count column increments +2 each time I am adding just one comment.</p> <p>I've looked through logs and increment query shows up there twice:</p> <pre><code> Started POST "/comments" for 127.0.0.1 at Mon May 21 16:39:49 +0200 2012 Processing by CommentsController#create as HTML Parameters: {"comment"=&gt;{"content_id"=&gt;"2803", "content_type"=&gt;"Post", "value"=&gt;"hello there"}, "authenticity_token"=&gt;"/2HRoMq/I+fPzLlKB8CezWEpwjywHo5RwCgm2VRj0zo=", "utf8"=&gt;"✓", "commit"=&gt;"Dodaj"} [1m[36mUser Load (0.4ms)[0m [1mSELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1[0m 1 row, 646 bajty app/controllers/application_controller.rb:27:in `current_user_session' app/controllers/application_controller.rb:32:in `current_user' app/controllers/application_controller.rb:41:in `require_user' [1m[35m (0.2ms)[0m BEGIN [1m[36m (1.0ms)[0m [1mUPDATE `users` SET `last_request_at` = '2012-05-21 14:39:50', `updated_at` = '2012-05-21 14:39:50', `perishable_token` = 'U6r38z0lX1G7Y48xC9s4' WHERE `users`.`id` = 1[0m [1m[35m (46.0ms)[0m COMMIT [1m[36m (0.2ms)[0m [1mBEGIN[0m [1m[35mBlacklist Load (0.7ms)[0m SELECT `blacklists`.* FROM `blacklists` WHERE (user_id = 1 AND end_date &gt; '2012-05-21 14:39:50') 0 rows, 0 bajty app/models/comment.rb:97:in `block_check' app/controllers/comments_controller.rb:25:in `create' [1m[36mSQL (0.6ms)[0m [1mINSERT INTO `comments` (`comments_count`, `content_id`, `content_type`, `created_at`, `edits`, `points`, `reported`, `updated_at`, `user_id`, `value`) VALUES (0, 2803, 'Post', '2012-05-21 14:39:50', 0, 0, NULL, '2012-05-21 14:39:50', 1, 'hello there')[0m [1m[35mPost Load (0.6ms)[0m SELECT `posts`.* FROM `posts` WHERE `posts`.`id` = 2803 LIMIT 1 1 row, 658 bajty app/controllers/comments_controller.rb:25:in `create' [1m[36mSQL (0.6ms)[0m [1mUPDATE `posts` SET `comments_count` = COALESCE(`comments_count`, 0) + 1 WHERE `posts`.`id` = 2803[0m [1m[35mSQL (0.4ms)[0m UPDATE `posts` SET `comments_count` = COALESCE(`comments_count`, 0) + 1 WHERE `posts`.`id` = 2803 [1m[36m (39.2ms)[0m [1mCOMMIT[0m Redirected to http://0.0.0.0:3000/news/zobacz/Tibia-obt-startuje-w-listopadzie-2 </code></pre> <p>I am trying to fix this whole day and I have no idea what is wrong. In development mode everything works OK. Problems appeared after upgrade from Rails2.</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