Skip to content

Instantly share code, notes, and snippets.

@0xjmp
Created January 30, 2014 01:25
Show Gist options
  • Save 0xjmp/8700948 to your computer and use it in GitHub Desktop.
Save 0xjmp/8700948 to your computer and use it in GitHub Desktop.
def index
@taxon = Spree::Taxon.where(permalink: params[:taxon]).first
raise ActiveRecord::RecordNotFound if @taxon.blank? || params[:taxon].match('swatch')
@category = @taxon.self_and_ancestors.where(depth: 1).first
@products = SizeFilterService.new(@taxon, params[:size]).filter!
@products = @products.inject([]) do |arr, product|
collection = product.collection
arr[collection.position] ||= [collection, []]
arr[collection.position][1] << product
arr
end.compact
@title = "Men's #{@taxon.name.titlecase}"
respond_to do |f|
f.json do
render json: @products
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment