Makes tag checking more efficient in Debates#index
1) Only loads the tags if params[:tag] is present 2) Only checks for existence of the tag, instead of loading them all and getting their names
This commit is contained in:
@@ -85,8 +85,9 @@ class DebatesController < ApplicationController
|
||||
end
|
||||
|
||||
def parse_tag_filter
|
||||
valid_tags = ActsAsTaggableOn::Tag.all.map(&:name)
|
||||
@tag_filter = params[:tag] if valid_tags.include?(params[:tag])
|
||||
if params[:tag].present?
|
||||
@tag_filter = params[:tag] if ActsAsTaggableOn::Tag.where(name: params[:tag]).exists?
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user