Created
April 14, 2011 07:53
-
-
Save dangalipo/919092 to your computer and use it in GitHub Desktop.
Why does it feel like im going about this the wrong way?
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.botttom_nodes | |
end | |
else | |
@search_trees = SearchTree.roots | |
end | |
authorize! :read, @search_trees | |
respond_with @search_trees do |format| | |
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