agenda-libre-ruby/app/controllers/tags_controller.rb

26 lines
658 B
Ruby
Raw Normal View History

# Manage event tags
2014-01-05 22:10:11 +01:00
class TagsController < InheritedResources::Base
has_scope :region, :locality, :daylimit
has_scope :period, type: :hash, using: [:year, :week]
has_scope :tag, as: :id
2014-01-05 22:10:11 +01:00
def index
@tags = apply_scopes(Event.moderated)
.pluck(:tags).map(&:split).flatten
.group_by { |i| i }
.map { |k, v| [k, v.size] }
.reject { |_k, v| v <= 3 }
.sort
respond_to do |format|
format.html
format.json { render json: @tags }
end
2014-01-05 22:10:11 +01:00
end
def show
@events_future = apply_scopes(Event).moderated.future
@events_past = apply_scopes(Event).moderated.past
2014-01-05 22:10:11 +01:00
end
end