Skip to content

Instantly share code, notes, and snippets.

@dangalipo
Created April 14, 2011 07:53
Show Gist options
  • Save dangalipo/919092 to your computer and use it in GitHub Desktop.
Save dangalipo/919092 to your computer and use it in GitHub Desktop.
Why does it feel like im going about this the wrong way?
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