好的,Github 回来了,现在我有了答案:
  要保留创建标签的顺序,请使用
  acts_as_ordered_taggable:
class User < ActiveRecord::Base
  # Alias for acts_as_ordered_taggable_on :tags
  acts_as_ordered_taggable
  acts_as_ordered_taggable_on :skills, :interests
end
@user = User.new(:name => "Bobby")
@user.tag_list = "east, south"
@user.save
@user.tag_list = "north, east, south, west"
@user.save
@user.reload
@user.tag_list # => ["north", "east", "south", "west"]
任何有兴趣复制此过程的人都可以执行以下操作:
<%= m.input :option_list, :label => "Options", :input_html => { :multiple => true } %>
(上面是 simple_form DSL)
然后,对于您的 JS,这将允许您粘贴以逗号分隔的文本并使其自动标记...并能够拖放标签:
$("#style_option_list").select2({ width: '220px', tags:[], tokenSeparators: [","]})
$('body').on('paste', '.select2-input', function() {
  // append a delimiter and trigger an update
  $(this).val(this.value + ',').trigger('input');
});
$("#style_option_list").select2("container").find("ul.select2-choices").sortable({
    containment: 'parent',
    start: function() { $("#style_option_list").select2("onSortStart"); },
    update: function() { $("#style_option_list").select2("onSortEnd"); }
});
不要忘记add acts_as_ordered_taggable_on :options你的模型