Fix long lines

This commit is contained in:
Pau Perez
2018-11-06 13:41:28 +00:00
parent 4155f086e0
commit 26d95b7250
2 changed files with 16 additions and 4 deletions

View File

@@ -76,7 +76,11 @@ Spree::Api::ProductsController.class_eval do
end
def render_paged_products(products)
render text: { products: ActiveModel::ArraySerializer.new(products, each_serializer: Api::Admin::ProductSerializer), pages: products.num_pages }.to_json
end
serializer = ActiveModel::ArraySerializer.new(
products,
each_serializer: Api::Admin::ProductSerializer
)
render text: { products: serializer, pages: products.num_pages }.to_json
end
end

View File

@@ -9,11 +9,19 @@ class Api::Admin::ProductSerializer < ActiveModel::Serializer
has_one :master, serializer: Api::Admin::VariantSerializer
def image_url
object.images.present? ? object.images.first.attachment.url(:product) : "/assets/noimage/product.png"
if object.images.present?
object.images.first.attachment.url(:product)
else
"/assets/noimage/product.png"
end
end
def thumb_url
object.images.present? ? object.images.first.attachment.url(:mini) : "/assets/noimage/mini.png"
if object.images.present?
object.images.first.attachment.url(:mini)
else
"/assets/noimage/mini.png"
end
end
def on_hand