Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't override followers_count if already defined #116

Open
marckohlbrugge opened this issue Aug 24, 2019 · 0 comments
Open

Don't override followers_count if already defined #116

marckohlbrugge opened this issue Aug 24, 2019 · 0 comments

Comments

@marckohlbrugge
Copy link

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.

@marckohlbrugge marckohlbrugge changed the title Don't override followers_count is already defined Don't override followers_count if already defined Aug 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant