开发者

acts_as_taggable_on with finders

开发者 https://www.devze.com 2022-12-26 18:36 出处:网络
I would like to use acts_as_taggable_on to do a auto suggest style tagging similar to stackoverflow below... that or facebook.

I would like to use acts_as_taggable_on to do a auto suggest style tagging similar to stackoverflow below... that or facebook.

But I'm unsure looking thru the rdocs what methods to use to pull all the various tags from a giving model.

Article.tag_counts_on(:tags)

That gives me all the tags... but i'd like to do something more advanced with a finder.. ie they start typing and i narrow the search... I'm sure this must have been done, so before I start reinventing the wh开发者_如何学Goeel and using the tag model directly could someone point me in the right direction?

Also... is there an easy way to limit the number of tags they can enter? I used

validates_presence_of :tag_list

To validate the tags, but what about limiting them to 5? Any easier way than using a validation to count commas? I would figure this quite common.

I found this style of autocomplete tagging: link text

but i really like stackoverflow's functionality more... anyone know of any other good autocomplete jquery solutions?

Thanks


Check out the jquery plugin called autocomplete


If you're willing to setup your results in JSON, then loopj's jQuery Tokenizing Autocomplete might be just the right jQuery plugin for you. For more examples, see the website or the demo.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号