LoginSignup
0
0

More than 1 year has passed since last update.

【rails】seed.rbを作成する

Posted at

seed.rbを書いてみる。

category = Category.create!(
  category_name: "food"
)

sale_status = SaleStatus.create!(
  sale_status_name: "sale"
)

product_status = ProductStatus.create!(
  product_status_name: "on-sale"
)

product = Product.create!(
  product_name: "sample_product",
  price: 1000,
  description: "サンプル製品です。",
  delete_flag: false,
  category_id: category.id,
  sale_status_id: sale_status.id,
  product_status_id: product_status.id
)

Purchase.create!(
  purchase_price: 1000,
  purchase_quantity: 1,
  purchase_company: "架空社",
  product_id: product.id
)

雑ですけど、自分のメモように。

seedは、書く順番が大切。
親から子へ、上から下に書く。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0