Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

find_by_resource_id always returns only the first result #11

Closed
styx opened this issue Dec 14, 2011 · 2 comments
Closed

find_by_resource_id always returns only the first result #11

styx opened this issue Dec 14, 2011 · 2 comments

Comments

@styx
Copy link

styx commented Dec 14, 2011

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
Copy link

cvrsor commented Dec 16, 2011

Hi styx,

I am facing the same issue here, see this comment

schneems added a commit that referenced this issue Dec 17, 2011
Problem was caused by an incorrectly named variable, and not identified due to rails class reloading in development.
@schneems
Copy link
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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants