You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
marckohlbrugge
changed the title
Don't override followers_count is already defined
Don't override followers_count if already defined
Aug 24, 2019
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 callingrecord.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 theself[: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.
The text was updated successfully, but these errors were encountered: