Convert rep template to rabl

This commit is contained in:
Rohan Mitchell
2014-05-29 17:18:27 +10:00
parent 7d73f7d7f2
commit 4c6a7622eb
2 changed files with 14 additions and 15 deletions

View File

@@ -0,0 +1,14 @@
collection @collection
attributes :id, :name
child supplied_products: :supplied_products do |product|
attributes :name
node(:supplier_name) { |p| p.supplier.andand.name }
node(:image_url) { |p| p.images.present? ? p.images.first.attachment.url(:mini) : nil }
node(:master_id) { |p| p.master.id }
child variants: :variants do |variant|
attributes :id
node(:label) { |v| v.options_text }
end
end

View File

@@ -1,15 +0,0 @@
r.list_of :enterprises, @collection do
r.element :id
r.element :name
r.list_of :supplied_products do |product|
r.element :name
r.element :supplier_name, product.supplier.andand.name
r.element :image_url, product.images.present? ? product.images.first.attachment.url(:mini) : nil
r.element :master_id, product.master.id
r.list_of :variants do |variant|
r.element :id
r.element :label, variant.options_text
end
end
end