Skip to content

Instantly share code, notes, and snippets.

@dangalipo
Created April 20, 2011 08:39
Show Gist options
  • Save dangalipo/930750 to your computer and use it in GitHub Desktop.
Save dangalipo/930750 to your computer and use it in GitHub Desktop.
Method
def index
if request.format.json?
if params[:product_type_id].present?
@search_trees = ProductType.find(params[:product_type_id]).search_trees
else
@search_trees = SearchTree.bottom_nodes
end
else
@search_trees = SearchTree.roots
end
authorize! :read, @search_trees
respond_to do |format|
format.html
format.json { render :json => @search_trees.map{|s| {:search_tree => {:name => s.short_label, :id => s.id}}}.to_json}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment