你如何实现一个内联可编辑标签字段,它具有接受新标签的自动完成功能?(rails 4)

How do you implement an inline editable tag field with autocomplete that accepts new tags ?(rails 4)

我需要制作一个内联 editable 字段,它也接受不在自动完成的 table 上的标签,就像 Whosebug 一样......我在 rails 4....

例如,如果我有 table 个动物,而这个 table 有 'cat'、'dog'、'whale'

然后有人输入 'fox' 我也需要接受该标签并将其保存以供将来提出建议。哪个是实现这个的最佳方法?如果我离开标签系统打开选项,我担心坏词会进入数据库。我怎样才能避免这种情况?在模型中验证标签的单词黑名单什么的?......

您可以使用 select2-rails gem, which allows you to integrate the Select2 jQuery plugin. Check out the tagging support example.