Skip to content

Instantly share code, notes, and snippets.

@universal
Last active May 31, 2016 07:54
Show Gist options
  • Save universal/00cfb818a10b505d554dba7958e4867c to your computer and use it in GitHub Desktop.
Save universal/00cfb818a10b505d554dba7958e4867c to your computer and use it in GitHub Desktop.
try to have a array of hash for put on jquery tre viewer...
class Travail < ActiveRecord::Base
def to_tree
Jbuilder.new do |build|
build.hash(self, :title, :id)
end
end
end
// controller/travails_controller.rb
class TravailsController < ApplicationController
def show
@comments = @travail.comments.with_state([:published])
gon.sscat = @travail.descendants.to_tree //failed
gon.sscat = @travail.to_tree.descendants //show array of array, but i would like array of hash data form => [{...}{...}...]
print "***** ==>"
print gon.sscat
respond_to do |f|
f.html
f.xml { render :xml => @travail }
end
end
end
$(document).on 'page:load page:update ready', ->
$('#sous_categories').tree
data: gon.sscat,
autoOpen: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment