Skip to content

Refactor: replace Page#tags_for_group with Page::TagSuggestions

azul requested to merge refactor/tags into master

Page class is way to big already anyway. Page::TagSuggestions was the main consumer of tags_for_group. Now tags_for_groups and its helper method access_filter are in TagSuggestions. TagSuggestions can be used directly in its place:

Page::TagSuggestions(group, current_user).all

is equivalent to what used to be

Page.tags_for_group(group, current_user)

The new version also works with users returning user.tags. However we only want to make use of this for current_user. Other peoples tags are none of current_users business.

So far the result is an Array. It might make sense to expose an ActiveRecord Query instead so recent or popular could be scopes on ActsAsTaggableOn::Tag instead of helper functions.

Merge request reports