我目前在Rails的acts_as_taggable_on插件中使用Model.tag_counts_on()方法时遇到了一些问题。我无法找到有关该方法的真实文档,我想了解更多有关它接受的参数的信息。我正在尝试在标记子集上获取标记计数,而不是我的应用程序上的整个标记集,我将如何进行此操作?
答案 0 :(得分:2)
假设您使用mbleigh/acts-as-taggable-on
这是方法出现的gem的master branch。
我会检查条件和参数。
def tag_counts_on(context, options = {})
all_tag_counts(options.merge({:on => context.to_s}))
end
##
# Calculate the tag counts for all tags.
#
# @param [Hash] options Options:
# * :start_at - Restrict the tags to those created after a certain time
# * :end_at - Restrict the tags to those created before a certain time
# * :conditions - A piece of SQL conditions to add to the query
# * :limit - The maximum number of tags to return
# * :order - A piece of SQL to order by. Eg 'tags.count desc' or 'taggings.created_at desc'
# * :at_least - Exclude tags with a frequency less than the given value
# * :at_most - Exclude tags with a frequency greater than the given value
# * :on - Scope the find to only include a certain context
def all_tag_counts(options = {})..end