Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Open
saravk opened this Issue · 5 comments

3 participants

@saravk

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)
      end
    end

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

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)
#SARAV-PATCH-START
#follows.create(:followable => self, :follower => follower, :blocked => true)
Follow.create(:followable => self, :follower => follower, :blocked => true)
#PATCH-END
end

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

def unblock(follower)
#SARAV-PATCH-START
#get_follow_for(follower).try(:delete)
follow = get_follow_for(follower)
if follow
follow.destroy
end
#PATCH-END
end

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

@tcocca
Owner

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.

Thanks,
~ Tom

@saravk

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.

t.block(u)
=> #
u.follow(t)
=> nil
t.followers
=> []
t.unblock(u)
NoMethodError: undefined method try' for #<Follow:0x102b44b70>
from /Users/saravanak/RailsWorks/kettikgit/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:256:in
method_missing'
from /Users/saravanak/RailsWorks/kettikgit/vendor/plugins/acts_as_follower/lib/acts_as_followable.rb:87:in `unblock'
from (irb):9

@saravk

sorry about the formatting above..

@tcocca
Owner

Thanks,

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

~ Tom

@jamesekennedy

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
Something went wrong with that request. Please try again.