0

我目前在 Rails 的acts_as_taggable_on 插件中的 Model.tag_counts_on() 方法上遇到了一些问题。我找不到有关该方法的真实文档,我想了解更多有关它接受的参数的信息。我正在尝试获取标签子集的标签计数,而不是我的应用程序上的整个标签集,我将如何去做?

4

1 回答 1

2

假设您正在使用mbleigh/acts-as-taggable-on

这是该方法出现的 gem的master 分支。

我会检查条件和参数。

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
于 2012-07-29T00:38:35.480 回答