uses tag ids instead of tag names

This commit is contained in:
rgarcia
2016-02-17 20:50:37 +01:00
parent f855ad6b3b
commit 9409190db1
2 changed files with 5 additions and 1 deletions

View File

@@ -42,7 +42,7 @@ class Proposal < ActiveRecord::Base
scope :sort_by_relevance , -> { all }
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)}
scope :in_categories, -> { where("tags.name IN (?)", ActsAsTaggableOn::Tag.category_names) }
scope :in_categories, -> { where("tags.id IN (?)", ActsAsTaggableOn::Tag.category_ids) }
def searchable_values
{ title => 'A',

View File

@@ -38,6 +38,10 @@ module ActsAsTaggableOn
Tag.where("kind = 'category'").map {|tag| tag.name.downcase }
end
def self.category_ids
Tag.where("kind = 'category'").map {|tag| tag.id }
end
private
def custom_counter_field_name_for(taggable_type)
"#{taggable_type.underscore.pluralize}_count"