cirandas.net

ref: master

plugins/elasticsearch/helpers/elasticsearch_plugin_helper.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
module ElasticsearchPluginHelper

  def categories_data(collection)
    result = []
    collection.each do | item |
      result.push({ text: item.name, id: item.id })
      result.last[:children] = categories_data(item.children) if item.children_count > 0
    end
    result
  end
end