2012-07-28 41 views
0

我目前在Rails的acts_as_taggable_on插件中的Model.tag_counts_on()方法中遇到了一些問題。我找不到關於該方法的真實文檔,我想更多地瞭解它接受的參數。我試圖在標籤子集上獲取標籤計數,而不是我應用程序中的整套標籤,我該如何去做這件事?acts_as_taggable_on Tag_counts_on()方法

回答

2

假設你正在使用mbleigh/acts-as-taggable-on

這是該方法出現在創業板的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