heartcombo/has_scope

Please allow extra options in `has_scope`

alaz opened this issue · 2 comments

alaz commented

has_scope validates the keys using assert_valid_keys, thus it's impossible to extend functionality adding new keys to the configuration.

What I was going to achieve. I have scopes and I would like to display how many items per scope. I have this functionality, and I was going to make use of has_scope configuration like so has_scope :filter, show_count: true and read show_count in my code via scopes_configuration.

Regards,
Alexander

alaz commented

Apparently it's more complicated than that. I am using apply_scopes w/ modified hash to calculate counts per filter, but it changes current_scopes as well, thus messing things in the view.

Hey @alaz, I believe this can be achieved by keeping a separate list of filters you'd like to show the count for, and then iterating over current_scopes and checking if they're in the show count list -- something along those lines.

If you have a more concrete example of what you're trying to achieve we may consider extending has_scope to allow custom options to be passed, but for now I think it's better to keep it's API small and list out all the possible options available there. Thanks!