Comments (5)
This is an odd one. If you're saying it works sometimes, for some posts, but not other posts. Is there any pattern with the posts that cannot be liked? Perhaps certain id's that cannot be liked?
I would recommend tailing the log to make sure that the initial post works to the controller
heroku logs --tail
For some additional insight you can take a look at the result of target = Likeable.find_by_resource_id(params[:resource_name], params[:resource_id])
by calling puts target.inspect
on the element to ensure it is being properly recovered from the database.
if that works every time, you can ensure the proper keys are being generated
puts target.like_key.inspect
puts current_user.like_key
If those look correct it is possible that your connection to redis is intermittent. You can try writing to redis directly
redis = Likeable.redis
puts redis.inspect # make sure this matches your redis-to-go information
puts redis.hset(target.like_key, current_user.id, Time.now.to_f)
puts redis.hkeys(target.like_key)
Let me know what the result of each of those tests are, and I can help trouble-shoot more. What version of Rails are you on?
from likeable.
Hi Richard,
Many thanks for your reply and help. Indeed, it is a very strange error: here's what I found after inspecting the elements you suggest:
- The post reaches the controller, I can see the 'Processing by LikesController#create as HTML' in the terminal window
puts target.inspect
correctly recovers the 'Post' element from database, all fields are shown correctly in the terminal window (#<Post id: 60, ...)puts target.like_key.inspect
correctly returns "Posts:like:60"puts current_user.like_key
returns Users:like:1
So I guess everything works fine until here.
Also, running redis = Likeable.redis
in rails console spits out correctly my RedisToGo connection string, and I can set the hash.
Really strange error..
Only pattern I've noticed is that the first attempt to like/unlike always succeeds and every subsequent attempt always fails..And if I restart the server and try the same record it succeeds, it seems that the redis connection works only for the fist POST and then its gone!
Just in case you spot any stupid mistakes:
config/initializers/likeable.rb```
Likeable.setup do |likeable|
uri = URI.parse(ENV["REDISTOGO_URL"])
likeable.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
end
Hey, many thanks for your help, really appreciated!
from likeable.
Don't know if it helps, I'm running Rails v.3.0.10. I really have no idea where to start for debugging..
from likeable.
Hi Richard,
I think my issue is the same as issue #11 opened by styx!
I had not spotted this before, my 'unsuccessful' posts were sending in the correct resource id, however the target returned by find_by_resource_id is always the first post that is made (from when server started).
Something funny could be going on in likeable / module_methods.rb and specifically in def find_one(klass, id)
Thanks!
from likeable.
Thanks again for reporting this, i updated notes in #11. Should be fixed with Gem Version 0.1.1
from likeable.
Related Issues (9)
- Likeable has some where calls HOT 1
- Rails 3.1 incompatible? HOT 3
- undefined method 'hkeys' for "localhost:5959":String HOT 1
- How can I get most liked items? HOT 2
- find_by_resource_id always returns only the first result HOT 2
- What is the most efficient way to create a 'likes' stream? HOT 4
- Users total likes HOT 4
- What if you need to restart a server or it fails? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from likeable.