Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

find_by_resource_id always returns only the first result #11

Closed
styx opened this Issue December 14, 2011 · 2 comments

3 participants

Mikhail S. Pobolovets Richard Schneeman cvrsor
Mikhail S. Pobolovets

I've tried the seq in rails c:

Likeable.find_by_resource_id("Comment", 15)
Likeable.find_by_resource_id("Comment", 16)
Likeable.find_by_resource_id("Comment", 56)

but I'm always getting 'Comment id: 15'

Here is the log what is going on:

>> Likeable.find_by_resource_id("Comment", 15)
  Comment Load (0.7ms)  SELECT "comments".* FROM "comments" WHERE "comments"."id" = 15 LIMIT 1
=> #<Comment id: 15, comment: "Your opinion about this product!!!", rating: 4, related: true, user_id: 8, product_id: 65, created_at: "2011-12-13 10:12:19", updated_at: "2011-12-13 10:12:19">
>> Likeable.find_by_resource_id("Comment", 16)
  Comment Load (0.7ms)  SELECT "comments".* FROM "comments" WHERE "comments"."id" = 15 LIMIT 1
=> #<Comment id: 15, comment: "Your opinion about this product!!!", rating: 4, related: true, user_id: 8, product_id: 65, created_at: "2011-12-13 10:12:19", updated_at: "2011-12-13 10:12:19">
>> Likeable.find_by_resource_id("Comment", 56)
  Comment Load (0.6ms)  SELECT "comments".* FROM "comments" WHERE "comments"."id" = 15 LIMIT 1
=> #<Comment id: 15, comment: "Your opinion about this product!!!", rating: 4, related: true, user_id: 8, product_id: 65, created_at: "2011-12-13 10:12:19", updated_at: "2011-12-13 10:12:19">

P.S. Rails 3.1.3 / Postgresql if matters.

cvrsor

Hi styx,

I am facing the same issue here, see this comment

Richard Schneeman schneems referenced this issue from a commit December 16, 2011
Richard Schneeman [GH-11] fix find_one bug.
Problem was caused by an incorrectly named variable, and not identified due to rails class reloading in development.
875fc47
Richard Schneeman
Owner

This was entirely my fault there was some variable scope problems with the instance lambda. I pushed a new gem out. Please give it a try and let me know if you have any problems.

Thanks for reporting this.

Richard Schneeman schneems closed this December 16, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.