acts_as_follower
acts_as_follower copied to clipboard
Don't override followers_count if already defined
I'm using a counter cache to set followers_count
on my followable model. Unfortunately the gem seems to override my attribute getter with its own method. So calling record.followers_count
still calls the gem's method and executes an unnecessary database query.
My current workaround is to once again override the followers_count
method on the followable model and simply return the self[:followers_count]
value. This seems like a bit of a hack though.
My proposed solution is for the gem's followers_count
method to only get defined if there's no such method yet.
What do you think? I'd be happy to make a PR if you agree with this approach.