Created
April 20, 2011 08:39
-
-
Save dangalipo/930750 to your computer and use it in GitHub Desktop.
Method
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
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