Merge pull request #275 from mlovic/filter-topic

Allow debates to be filtered by topic
This commit is contained in:
Raimond Garcia
2015-08-28 17:41:38 +02:00
8 changed files with 88 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
class DebatesController < ApplicationController
before_action :parse_order, only: :index
before_action :parse_order, :parse_tag_filter, only: :index
before_action :authenticate_user!, except: [:index, :show]
load_and_authorize_resource
@@ -77,4 +77,9 @@ class DebatesController < ApplicationController
@order = @valid_orders.include?(params[:order]) ? params[:order] : 'created_at'
end
def parse_tag_filter
valid_tags = ActsAsTaggableOn::Tag.all.map(&:name)
@tag_filter = params[:tag] if valid_tags.include?(params[:tag])
end
end