Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
xml.instruct! | ||
xml.products do | ||
@products.each do |product| | ||
xml.product do | ||
xml.name product.name | ||
xml.quantity product.quantity | ||
xml.category product.category.name | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# app/views/products/products_by_category.xml.builder | ||
|
||
xml.instruct! | ||
xml.products_by_category do | ||
@categories.each do |category| | ||
xml.category do | ||
xml.name category.name | ||
category.products.each do |product| | ||
xml.product do | ||
xml.name product.name | ||
xml.quantity product.quantity | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
xml.instruct! | ||
xml.product do | ||
xml.name @product.name | ||
xml.quantity(@product.quantity, type: 'integer') | ||
xml.category @product.category.name | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
Rails.application.routes.draw do | ||
root "products#index" | ||
resources :products | ||
get '/products_by_category', to: 'products#products_by_category' | ||
resources :categories | ||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | ||
end |