summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-04 19:54:00 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-04 19:54:00 -0600
commit18b129f8f6ba8c5c98adaf82ccfc4ba38264a29b (patch)
tree90b0bb96064198fec5747a55b65e3f419a5cb0e8
parent72ccdfdf9bbea6269bc1a28199373abd5e8ce302 (diff)
Añade modelo Cart
-rw-r--r--app/models/cart.rb6
-rw-r--r--db/migrate/20230405013826_create_carts.rb9
-rw-r--r--db/schema.rb10
-rw-r--r--spec/models/cart_spec.rb5
4 files changed, 29 insertions, 1 deletions
diff --git a/app/models/cart.rb b/app/models/cart.rb
new file mode 100644
index 0000000..f9e5ea0
--- /dev/null
+++ b/app/models/cart.rb
@@ -0,0 +1,6 @@
+# frozen_string_literal: true
+
+# Cart
+class Cart < ApplicationRecord
+ has_one :user_account
+end
diff --git a/db/migrate/20230405013826_create_carts.rb b/db/migrate/20230405013826_create_carts.rb
new file mode 100644
index 0000000..8975e61
--- /dev/null
+++ b/db/migrate/20230405013826_create_carts.rb
@@ -0,0 +1,9 @@
+class CreateCarts < ActiveRecord::Migration[7.0]
+ def change
+ create_table :carts do |t|
+ t.belongs_to :user_account, null: false, index: { unique: true }, foreign_key: true
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index fc2bbd1..5c4292f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.0].define(version: 2023_04_04_004859) do
+ActiveRecord::Schema[7.0].define(version: 2023_04_05_013826) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -61,6 +61,13 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_04_004859) do
t.index ["user_account_id"], name: "index_cards_on_user_account_id"
end
+ create_table "carts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
+ t.bigint "user_account_id", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["user_account_id"], name: "index_carts_on_user_account_id", unique: true
+ end
+
create_table "companies", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t|
t.string "name"
t.string "country"
@@ -118,6 +125,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_04_04_004859) do
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "cards", "user_accounts"
+ add_foreign_key "carts", "user_accounts"
add_foreign_key "product_reviews", "products"
add_foreign_key "product_reviews", "user_accounts"
add_foreign_key "products", "companies"
diff --git a/spec/models/cart_spec.rb b/spec/models/cart_spec.rb
new file mode 100644
index 0000000..5985277
--- /dev/null
+++ b/spec/models/cart_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe Cart, type: :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end