30 Aug '14, 6pm

Ruby/Rails/Redis Friends/Followers System

module Bearbrandd module Friendable # follow a user def follow!(user) Redis.current.multi do Redis.current.sadd(self.redis_key(:following), user.id) Redis.current.sadd(user.redis_key(:followers), self.id) end end # unfollow a user def unfollow!(user) Redis.current.multi do Redis.current.srem(self.redis_key(:following), user.id) Redis.current.srem(user.redis_key(:followers), self.id) end end # users that self follows def followers user_ids = Redis.current.smembers(self.redis_key(:followers)) User.where(:id => user_ids) end # users that follow self def following user_ids = Redis.current.smembers(self.redis_key(:following)) User.where(:id => user_ids) end # users who follow and are being followed by self def friends user_ids = Redis.current.sinter(self.redis_key(:following), self.redis_key(:followers)) User.where(:id => user_ids) end # does the user follow self def followed_b...

Full article: http://eggie5.com/52-ruby-rails-redis-friends-followers-s...

Tweets

Ruby/Rails/#Redis Friends/Followers System

eggie5.com 05 Sep '14, 6pm

2010-11-13 Customize "share picture via" menu on Android (Android Intent Filters) 2014-08-23 iOS Tinder-style Swipe 2014-0...

Ruby/Rails/#Redis Friends/Followers System

eggie5.com 05 Sep '14, 6pm

module Bearbrandd module Friendable # follow a user def follow!(user) Redis.current.multi do Redis.current.sadd(self.redis...

auto followers new Ya/Tidak kamu suka durian

mzaam507.us.to 06 Sep '14, 2pm

Dapatkan 100 Follower setiap 3 menit. Silakan login terlebih dahulu Sebelum menggunakan aplikasi ini, mohon baca Peraturan...