Tags can also be scoped by region and week/year

This commit is contained in:
echarp 2015-11-11 10:37:55 +01:00
parent 11191169ce
commit a00fb8aa92
1 changed files with 6 additions and 3 deletions

View File

@ -1,7 +1,10 @@
# Manage event tags
class TagsController < InheritedResources::Base
has_scope :region, :locality, :tag, :daylimit
has_scope :period, type: :hash, using: [:year, :week]
def index
@tags = Event
@tags = apply_scopes(Event.moderated)
.pluck(:tags).map(&:split).flatten
.group_by { |i| i }
.map { |k, v| [k, v.size] }
@ -15,7 +18,7 @@ class TagsController < InheritedResources::Base
end
def show
@events_future = Event.moderated.future.tag params[:id]
@events_past = Event.moderated.past.tag params[:id]
@events_future = apply_scopes(Event).moderated.future.tag params[:id]
@events_past = apply_scopes(Event).moderated.past.tag params[:id]
end
end