Issues with block functionality (Rails 2.3.x) #7

saravk opened this Issue Dec 17, 2010 · 6 comments


None yet
4 participants

saravk commented Dec 17, 2010

First off i'd like to say that this plugin is a godsend. I was able to implement a comment notification system for my website in minutes. One of the features for the notification system is to let the user block himself from receiving notifications for a particular topic.

But the block system in the plugin did not seem to work, so i added a few patches to my local code. I have to say that im not very proficient with rails coding, so do ignore the chunky code.

Issue1: follow method should check if there is a blocked entry before creating a new Follow record

def follow(followable) #SARAV-PATCH-START #if a blocked record exists then do not follow unless get_blocked_follow(followable).blank? return end #PATCH-END
      follow = get_follow(followable)
      if follow.blank? && self != followable
        Follow.create(:followable => followable, :follower => self)

    def get_blocked_follow(followable)
      Follow.blocked.find(:first, :conditions => ["follower_id = ? AND follower_type = ? AND followable_id = ? AND followable_type = ?",, parent_class_name(self),, parent_class_name(followable)])

The next 2 issues could be something to do with my environment. But as i said im not very familiar with rails, so i just patched it.

Issue 2: NameError: undefined local variable or method `follows' in In block_future_follow

def block_future_follow(follower)
#follows.create(:followable => self, :follower => follower, :blocked => true)
Follow.create(:followable => self, :follower => follower, :blocked => true)

Issue 3: NoMethodError: undefined method `try' in unblock method

def unblock(follower)
follow = get_follow_for(follower)
if follow

Please let me know if my changes are alright.. And thanks again for this wonderful plugin


tcocca commented Dec 17, 2010

Thanks sarav, are you using rails 2.3.x or rails 3?

If rails 3 are you using the rails3 branch of the plugin?

I could see #1 being and issue and I'll investigate further #2. But #3 I am confused on. #try is an activesupport method so if you are using it in rails that should work...

I'll look into it soon.

~ Tom

saravk commented Dec 17, 2010

Im using rails 2.3.x and i installed from the main branch (as mentioned in the README doc)

For #3, please check the console output.

=> #<Follow id: 26, followable_id: 2, followable_type: "Talktopic", follower_id: 2, follower_type: "User", blocked: true, created_at: "2010-12-17 19:56:32", updated_at: "2010-12-17 19:56:32">
=> nil
=> []
NoMethodError: undefined method try' for #<Follow:0x102b44b70> from /Users/saravanak/RailsWorks/kettikgit/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:256:inmethod_missing'
from /Users/saravanak/RailsWorks/kettikgit/vendor/plugins/acts_as_follower/lib/acts_as_followable.rb:87:in `unblock'
from (irb):9

saravk commented Dec 17, 2010

sorry about the formatting above..


tcocca commented Dec 17, 2010


I will be sure to check these out. Thanks for the reports.

~ Tom

I am also getting ...

User Load (0.3ms) SELECT "users".* FROM "users" LIMIT 1
NoMethodError: Follow Load (0.3ms) SELECT "follows".* FROM "follows" WHERE "follows"."followable_id" = 1 AND "follows"."followable_type" = 'User'
undefined method `unblocked' for []:ActiveRecord::Relation

when calling User.first.followers. I'm running rails 3.2.8 though.

Looking forward to getting this working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment