Created
May 3, 2014 01:27
-
-
Save 0xjmp/1fe3b68a72ff64b17cdb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| json.products @products do |product| | |
| json.(product, :id, :price, :permalink) | |
| end |
This file contains hidden or 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 | |
| taxon = Spree::Taxon.where(permalink: params[:taxon]).first | |
| raise InvalidTaxon if taxon.blank? || params[:taxon].match('swatch') | |
| @products = SizeFilterService.new(taxon, params).filter! | |
| end |
This file contains hidden or 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
| Jbuilder.encode do |json| | |
| json.(@product, :id, :name, :sku, :description, :price) | |
| json.permalink @product.slug | |
| json.in_stock @product.in_stock? | |
| json.collection @product.collection.name.titelize if @product.collection.present? | |
| json.images @product.images do |image| | |
| json.original_image_url image.attachment.url(:original) | |
| json.image_url image.attachment.url(:product_medium) | |
| json.large_image_url image.attachment.url(:large) | |
| json.mini_image_url image.attachment.url(:mini) | |
| end | |
| json.variants @product.variants do |variant| | |
| json.(variant, :sku, :id, :product_id) | |
| json.in_stock variant.in_stock? | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment