Last active
May 31, 2016 07:54
-
-
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...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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