Merge pull request #275 from mlovic/filter-topic
Allow debates to be filtered by topic
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user