Skip to content

Commit 9c2b515

Browse files
committed
Create products seed
1 parent 6207b0a commit 9c2b515

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

pdv/app/controllers/products_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ class ProductsController < ApplicationController
55
def index
66
@products = Product.all
77

8-
render json: @products
8+
render json: {data: @products}
99
end
1010

1111
# GET /products/1
1212
def show
13-
render json: @product
13+
render json: {data: @product}
1414
end
1515

1616
# POST /products

pdv/db/seeds.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@
2323
access: 1,
2424
name: 'Vinicius Arruda')
2525

26+
10.times do
27+
Product.create({
28+
sku: Faker::Number.number(6),
29+
item: Faker::Book.title,
30+
color: Faker::Color.hex_color,
31+
size: 'M',
32+
cod: Faker::Number.between(1, 50),
33+
stock: Faker::Number.between(1, 20)
34+
})
35+
end

0 commit comments

Comments
 (0)