From cdca3e3a1155271647c329cbcb4a9131763bf9fe Mon Sep 17 00:00:00 2001 From: woolosh Date: Tue, 26 Jan 2021 10:06:06 -0600 Subject: [PATCH 1/8] created models --- lib/Inventory.rb | 0 lib/Items.rb | 0 lib/Purchase.rb | 0 lib/Stores.rb | 0 lib/Users.rb | 0 5 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 lib/Inventory.rb create mode 100644 lib/Items.rb create mode 100644 lib/Purchase.rb create mode 100644 lib/Stores.rb create mode 100644 lib/Users.rb diff --git a/lib/Inventory.rb b/lib/Inventory.rb new file mode 100644 index 00000000..e69de29b diff --git a/lib/Items.rb b/lib/Items.rb new file mode 100644 index 00000000..e69de29b diff --git a/lib/Purchase.rb b/lib/Purchase.rb new file mode 100644 index 00000000..e69de29b diff --git a/lib/Stores.rb b/lib/Stores.rb new file mode 100644 index 00000000..e69de29b diff --git a/lib/Users.rb b/lib/Users.rb new file mode 100644 index 00000000..e69de29b From f13a982c4de1c09ea0a45edf265f0e16080d9af5 Mon Sep 17 00:00:00 2001 From: woolosh Date: Wed, 27 Jan 2021 13:56:45 -0600 Subject: [PATCH 2/8] added db files --- lib/Items.rb => db/migrate/01_create_users_table.rb | 0 lib/{Stores.rb => Item.rb} | 0 lib/{Users.rb => Store.rb} | 0 lib/User.rb | 2 ++ 4 files changed, 2 insertions(+) rename lib/Items.rb => db/migrate/01_create_users_table.rb (100%) rename lib/{Stores.rb => Item.rb} (100%) rename lib/{Users.rb => Store.rb} (100%) create mode 100644 lib/User.rb diff --git a/lib/Items.rb b/db/migrate/01_create_users_table.rb similarity index 100% rename from lib/Items.rb rename to db/migrate/01_create_users_table.rb diff --git a/lib/Stores.rb b/lib/Item.rb similarity index 100% rename from lib/Stores.rb rename to lib/Item.rb diff --git a/lib/Users.rb b/lib/Store.rb similarity index 100% rename from lib/Users.rb rename to lib/Store.rb diff --git a/lib/User.rb b/lib/User.rb new file mode 100644 index 00000000..431cf7ba --- /dev/null +++ b/lib/User.rb @@ -0,0 +1,2 @@ +class User < ActiveRecord::Base +end \ No newline at end of file From 98df15fed61aa6da70be80c0be0beddc986b318f Mon Sep 17 00:00:00 2001 From: eCoder321 Date: Wed, 27 Jan 2021 15:35:27 -0500 Subject: [PATCH 3/8] database _creation_&_first_activerecord_migration --- db/migrate/20210127191926_create_inventory.rb | 12 ++++ db/migrate/20210127192037_create_items.rb | 9 +++ db/migrate/20210127192047_create_purchase.rb | 10 ++++ db/migrate/20210127192055_create_stores.rb | 10 ++++ db/migrate/20210127192100_create_users.rb | 10 ++++ db/schema.rb | 55 +++++++++++++++++++ db/seeds.rb | 18 ++++++ lib/Inventory.rb | 2 + lib/Items.rb | 2 + lib/Purchase.rb | 2 + lib/Stores.rb | 2 + lib/Users.rb | 2 + 12 files changed, 134 insertions(+) create mode 100644 db/migrate/20210127191926_create_inventory.rb create mode 100644 db/migrate/20210127192037_create_items.rb create mode 100644 db/migrate/20210127192047_create_purchase.rb create mode 100644 db/migrate/20210127192055_create_stores.rb create mode 100644 db/migrate/20210127192100_create_users.rb create mode 100644 db/schema.rb create mode 100644 db/seeds.rb diff --git a/db/migrate/20210127191926_create_inventory.rb b/db/migrate/20210127191926_create_inventory.rb new file mode 100644 index 00000000..fdc791e2 --- /dev/null +++ b/db/migrate/20210127191926_create_inventory.rb @@ -0,0 +1,12 @@ +class CreateInventory < ActiveRecord::Migration[6.1] + def change + create_table :inventories do + |inventory| + inventory.references :user + inventory.references :item + inventory.float :price + inventory.integer :quantity + inventory.timestamps + end + end +end diff --git a/db/migrate/20210127192037_create_items.rb b/db/migrate/20210127192037_create_items.rb new file mode 100644 index 00000000..0f572aa2 --- /dev/null +++ b/db/migrate/20210127192037_create_items.rb @@ -0,0 +1,9 @@ +class CreateItems < ActiveRecord::Migration[6.1] + def change + create_table :items do + |item| + item.string :name + item.timestamps + end + end +end diff --git a/db/migrate/20210127192047_create_purchase.rb b/db/migrate/20210127192047_create_purchase.rb new file mode 100644 index 00000000..5286ef6a --- /dev/null +++ b/db/migrate/20210127192047_create_purchase.rb @@ -0,0 +1,10 @@ +class CreatePurchase < ActiveRecord::Migration[6.1] + def change + create_table :purchases do + |t| + t.references :item + t.references :user + t.timestamps + end + end +end diff --git a/db/migrate/20210127192055_create_stores.rb b/db/migrate/20210127192055_create_stores.rb new file mode 100644 index 00000000..293dcc35 --- /dev/null +++ b/db/migrate/20210127192055_create_stores.rb @@ -0,0 +1,10 @@ +class CreateStores < ActiveRecord::Migration[6.1] + def change + create_table :stores do + |store| + store.string :name + store.string :address + store.timestamps + end + end +end diff --git a/db/migrate/20210127192100_create_users.rb b/db/migrate/20210127192100_create_users.rb new file mode 100644 index 00000000..2d850635 --- /dev/null +++ b/db/migrate/20210127192100_create_users.rb @@ -0,0 +1,10 @@ +class CreateUsers < ActiveRecord::Migration[6.1] + def change + create_table :users do + |t| + t.string :name + t.string :address + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 00000000..26c7a0d5 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,55 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2021_01_27_192100) do + + create_table "inventories", force: :cascade do |t| + t.integer "user_id" + t.integer "item_id" + t.float "price" + t.integer "quantity" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["item_id"], name: "index_inventories_on_item_id" + t.index ["user_id"], name: "index_inventories_on_user_id" + end + + create_table "items", force: :cascade do |t| + t.string "name" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + + create_table "purchases", force: :cascade do |t| + t.integer "item_id" + t.integer "user_id" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["item_id"], name: "index_purchases_on_item_id" + t.index ["user_id"], name: "index_purchases_on_user_id" + end + + create_table "stores", force: :cascade do |t| + t.string "name" + t.string "address" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + + create_table "users", force: :cascade do |t| + t.string "name" + t.string "address" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 00000000..93464480 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,18 @@ +# User.all.destroy +# Inventory.all.destroy +# Item.all.destroy +# Purchase.all.destroy +# Store.all.destroy + +alex = User.create(name: "Alex", address: "1440 G St. NW, Washington DC 20001") +truce = User.create(name: "Truce", address: "60008 Franklin square, Washington D.C. 20015") +bode = User.create(name: "Bode", address: "5959 Dublin street, Washington D.C. 20033") + +shoppers = Store.create(name: "Shoppers World", address: "1259 Washington Boulevard, D.C. 20002") +walmart = Store.create(name: "Walmart", address: "5288 Mushin street, D.C. 20019") +costco = Store.create(name: "Costco", address: "5 Oily way, Washington D.C. 20012") + + +bread = Item.create(name:'Bread') +sweetnsour = Item.create(name:'Sweet N Sour') +mixed_nuts = Item.create(name: "Mixed Nuts - salted") \ No newline at end of file diff --git a/lib/Inventory.rb b/lib/Inventory.rb index e69de29b..73026556 100644 --- a/lib/Inventory.rb +++ b/lib/Inventory.rb @@ -0,0 +1,2 @@ +class Inventory < ActiveRecord::Base +end \ No newline at end of file diff --git a/lib/Items.rb b/lib/Items.rb index e69de29b..3897ab31 100644 --- a/lib/Items.rb +++ b/lib/Items.rb @@ -0,0 +1,2 @@ +class Item < ActiveRecord::Base +end \ No newline at end of file diff --git a/lib/Purchase.rb b/lib/Purchase.rb index e69de29b..cab98ca3 100644 --- a/lib/Purchase.rb +++ b/lib/Purchase.rb @@ -0,0 +1,2 @@ +class Purchase < ActiveRecord::Base +end \ No newline at end of file diff --git a/lib/Stores.rb b/lib/Stores.rb index e69de29b..5ec93f63 100644 --- a/lib/Stores.rb +++ b/lib/Stores.rb @@ -0,0 +1,2 @@ +class Store < ActiveRecord::Base +end \ No newline at end of file diff --git a/lib/Users.rb b/lib/Users.rb index e69de29b..431cf7ba 100644 --- a/lib/Users.rb +++ b/lib/Users.rb @@ -0,0 +1,2 @@ +class User < ActiveRecord::Base +end \ No newline at end of file From 788ee84ba38071874ab12aeac94468bacc906624 Mon Sep 17 00:00:00 2001 From: eCoder321 Date: Wed, 27 Jan 2021 16:42:43 -0500 Subject: [PATCH 4/8] updated the mifration folders --- Gemfile.lock | 67 +++++++++---------- db/migrate/20210127191926_create_inventory.rb | 12 ++-- db/migrate/20210127192037_create_items.rb | 6 +- db/migrate/20210127192055_create_stores.rb | 8 +-- db/migrate/20210127192100_create_users.rb | 2 +- db/schema.rb | 6 +- 6 files changed, 50 insertions(+), 51 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9589226d..af32595c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,47 +1,46 @@ GEM remote: https://rubygems.org/ specs: - activemodel (6.0.3.1) - activesupport (= 6.0.3.1) - activerecord (6.0.3.1) - activemodel (= 6.0.3.1) - activesupport (= 6.0.3.1) - activesupport (6.0.3.1) + activemodel (6.1.1) + activesupport (= 6.1.1) + activerecord (6.1.1) + activemodel (= 6.1.1) + activesupport (= 6.1.1) + activesupport (6.1.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) - coderay (1.1.1) - concurrent-ruby (1.1.6) - i18n (1.8.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + coderay (1.1.3) + concurrent-ruby (1.1.8) + i18n (1.8.7) concurrent-ruby (~> 1.0) - method_source (0.8.2) - minitest (5.14.1) - mustermann (1.0.3) - pry (0.10.4) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) + method_source (1.0.0) + minitest (5.14.3) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + pry (0.13.1) + coderay (~> 1.1) + method_source (~> 1.0) rack (2.2.3) - rack-protection (2.0.7) + rack-protection (2.1.0) rack - require_all (1.3.3) - sinatra (2.0.7) + require_all (3.0.0) + ruby2_keywords (0.0.4) + sinatra (2.1.0) mustermann (~> 1.0) - rack (~> 2.0) - rack-protection (= 2.0.7) + rack (~> 2.2) + rack-protection (= 2.1.0) tilt (~> 2.0) - sinatra-activerecord (2.0.12) - activerecord (>= 3.2) + sinatra-activerecord (2.0.22) + activerecord (>= 4.1) sinatra (>= 1.0) - slop (3.6.0) - sqlite3 (1.3.13) - thread_safe (0.3.6) + sqlite3 (1.4.2) tilt (2.0.10) - tzinfo (1.2.7) - thread_safe (~> 0.1) - zeitwerk (2.3.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + zeitwerk (2.4.2) PLATFORMS ruby @@ -53,4 +52,4 @@ DEPENDENCIES sqlite3 BUNDLED WITH - 1.14.6 + 1.17.3 diff --git a/db/migrate/20210127191926_create_inventory.rb b/db/migrate/20210127191926_create_inventory.rb index fdc791e2..241a1cd5 100644 --- a/db/migrate/20210127191926_create_inventory.rb +++ b/db/migrate/20210127191926_create_inventory.rb @@ -1,12 +1,12 @@ class CreateInventory < ActiveRecord::Migration[6.1] def change create_table :inventories do - |inventory| - inventory.references :user - inventory.references :item - inventory.float :price - inventory.integer :quantity - inventory.timestamps + |t| + t.references :store + t.references :item + t.float :price + t.integer :quantity + t.timestamps end end end diff --git a/db/migrate/20210127192037_create_items.rb b/db/migrate/20210127192037_create_items.rb index 0f572aa2..f4fbb688 100644 --- a/db/migrate/20210127192037_create_items.rb +++ b/db/migrate/20210127192037_create_items.rb @@ -1,9 +1,9 @@ class CreateItems < ActiveRecord::Migration[6.1] def change create_table :items do - |item| - item.string :name - item.timestamps + |t| + t.string :name + t.timestamps end end end diff --git a/db/migrate/20210127192055_create_stores.rb b/db/migrate/20210127192055_create_stores.rb index 293dcc35..922ac1b0 100644 --- a/db/migrate/20210127192055_create_stores.rb +++ b/db/migrate/20210127192055_create_stores.rb @@ -1,10 +1,10 @@ class CreateStores < ActiveRecord::Migration[6.1] def change create_table :stores do - |store| - store.string :name - store.string :address - store.timestamps + |t| + t.string :name + t.string :address + t.timestamps end end end diff --git a/db/migrate/20210127192100_create_users.rb b/db/migrate/20210127192100_create_users.rb index 2d850635..7edbb726 100644 --- a/db/migrate/20210127192100_create_users.rb +++ b/db/migrate/20210127192100_create_users.rb @@ -3,7 +3,7 @@ def change create_table :users do |t| t.string :name - t.string :address + t.string :current_location t.timestamps end end diff --git a/db/schema.rb b/db/schema.rb index 26c7a0d5..b9946148 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,14 +13,14 @@ ActiveRecord::Schema.define(version: 2021_01_27_192100) do create_table "inventories", force: :cascade do |t| - t.integer "user_id" + t.integer "store_id" t.integer "item_id" t.float "price" t.integer "quantity" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["item_id"], name: "index_inventories_on_item_id" - t.index ["user_id"], name: "index_inventories_on_user_id" + t.index ["store_id"], name: "index_inventories_on_store_id" end create_table "items", force: :cascade do |t| @@ -47,7 +47,7 @@ create_table "users", force: :cascade do |t| t.string "name" - t.string "address" + t.string "current_location" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end From 4c12fdd7bef67f149482260b406ca129fb04cf9e Mon Sep 17 00:00:00 2001 From: eCoder321 Date: Wed, 27 Jan 2021 16:43:47 -0500 Subject: [PATCH 5/8] created a concerns folder in libb for modules --- lib/concerns/Instance_method_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 lib/concerns/Instance_method_helper.rb diff --git a/lib/concerns/Instance_method_helper.rb b/lib/concerns/Instance_method_helper.rb new file mode 100644 index 00000000..eee4a7fc --- /dev/null +++ b/lib/concerns/Instance_method_helper.rb @@ -0,0 +1,5 @@ +class InstanceMethodHelper + def zip + address.split.last.to_i + end +end From 926e6f9fa15529c6e8f37e8b2d7002c2d9e74a92 Mon Sep 17 00:00:00 2001 From: eCoder321 Date: Wed, 27 Jan 2021 17:30:06 -0500 Subject: [PATCH 6/8] associated classes based on relations --- db/seeds.rb | 6 +++--- lib/Inventory.rb | 2 ++ lib/Items.rb | 4 ++++ lib/Purchase.rb | 2 ++ lib/Stores.rb | 2 ++ lib/Users.rb | 2 ++ 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 93464480..1e992b2b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,9 +4,9 @@ # Purchase.all.destroy # Store.all.destroy -alex = User.create(name: "Alex", address: "1440 G St. NW, Washington DC 20001") -truce = User.create(name: "Truce", address: "60008 Franklin square, Washington D.C. 20015") -bode = User.create(name: "Bode", address: "5959 Dublin street, Washington D.C. 20033") +alex = User.create(name: "Alex", current_location: "1440 G St. NW, Washington DC 20001") +truce = User.create(name: "Truce", current_location: "60008 Franklin square, Washington D.C. 20015") +bode = User.create(name: "Bode", current_location: "5959 Dublin street, Washington D.C. 20033") shoppers = Store.create(name: "Shoppers World", address: "1259 Washington Boulevard, D.C. 20002") walmart = Store.create(name: "Walmart", address: "5288 Mushin street, D.C. 20019") diff --git a/lib/Inventory.rb b/lib/Inventory.rb index 73026556..a7580968 100644 --- a/lib/Inventory.rb +++ b/lib/Inventory.rb @@ -1,2 +1,4 @@ class Inventory < ActiveRecord::Base + belongs_to :store + belongs_to :item end \ No newline at end of file diff --git a/lib/Items.rb b/lib/Items.rb index 3897ab31..a82f6e70 100644 --- a/lib/Items.rb +++ b/lib/Items.rb @@ -1,2 +1,6 @@ class Item < ActiveRecord::Base + has_many :inventories + has_many :stores, through: :inventories + has_many :purchases + has_many :users, through: :purchases end \ No newline at end of file diff --git a/lib/Purchase.rb b/lib/Purchase.rb index cab98ca3..0a6af65d 100644 --- a/lib/Purchase.rb +++ b/lib/Purchase.rb @@ -1,2 +1,4 @@ class Purchase < ActiveRecord::Base + belongs_to :item + belongs_to :user end \ No newline at end of file diff --git a/lib/Stores.rb b/lib/Stores.rb index 5ec93f63..c05754e6 100644 --- a/lib/Stores.rb +++ b/lib/Stores.rb @@ -1,2 +1,4 @@ class Store < ActiveRecord::Base + has_many :inventories + has_many :items, through: :inventories end \ No newline at end of file diff --git a/lib/Users.rb b/lib/Users.rb index 431cf7ba..2928278d 100644 --- a/lib/Users.rb +++ b/lib/Users.rb @@ -1,2 +1,4 @@ class User < ActiveRecord::Base + has_many :purchases + has_many :items, through: :purchases end \ No newline at end of file From 24935bece676300cdfc81512b3fc2cd94d7f913c Mon Sep 17 00:00:00 2001 From: eCoder321 Date: Wed, 27 Jan 2021 17:44:08 -0500 Subject: [PATCH 7/8] changed User to Customer across the board --- db/migrate/20210127192047_create_purchase.rb | 2 +- ...s.rb => 20210127192100_create_customers.rb} | 4 ++-- db/schema.rb | 18 +++++++++--------- db/seeds.rb | 8 ++++---- lib/{Users.rb => Customers.rb} | 2 +- lib/Items.rb | 2 +- lib/Purchase.rb | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) rename db/migrate/{20210127192100_create_users.rb => 20210127192100_create_customers.rb} (57%) rename lib/{Users.rb => Customers.rb} (65%) diff --git a/db/migrate/20210127192047_create_purchase.rb b/db/migrate/20210127192047_create_purchase.rb index 5286ef6a..15398dd0 100644 --- a/db/migrate/20210127192047_create_purchase.rb +++ b/db/migrate/20210127192047_create_purchase.rb @@ -3,7 +3,7 @@ def change create_table :purchases do |t| t.references :item - t.references :user + t.references :customer t.timestamps end end diff --git a/db/migrate/20210127192100_create_users.rb b/db/migrate/20210127192100_create_customers.rb similarity index 57% rename from db/migrate/20210127192100_create_users.rb rename to db/migrate/20210127192100_create_customers.rb index 7edbb726..efd05e39 100644 --- a/db/migrate/20210127192100_create_users.rb +++ b/db/migrate/20210127192100_create_customers.rb @@ -1,6 +1,6 @@ -class CreateUsers < ActiveRecord::Migration[6.1] +class CreateCustomers < ActiveRecord::Migration[6.1] def change - create_table :users do + create_table :customers do |t| t.string :name t.string :current_location diff --git a/db/schema.rb b/db/schema.rb index b9946148..172fcd5e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -12,6 +12,13 @@ ActiveRecord::Schema.define(version: 2021_01_27_192100) do + create_table "customers", force: :cascade do |t| + t.string "name" + t.string "current_location" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + create_table "inventories", force: :cascade do |t| t.integer "store_id" t.integer "item_id" @@ -31,11 +38,11 @@ create_table "purchases", force: :cascade do |t| t.integer "item_id" - t.integer "user_id" + t.integer "customer_id" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.index ["customer_id"], name: "index_purchases_on_customer_id" t.index ["item_id"], name: "index_purchases_on_item_id" - t.index ["user_id"], name: "index_purchases_on_user_id" end create_table "stores", force: :cascade do |t| @@ -45,11 +52,4 @@ t.datetime "updated_at", precision: 6, null: false end - create_table "users", force: :cascade do |t| - t.string "name" - t.string "current_location" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false - end - end diff --git a/db/seeds.rb b/db/seeds.rb index 1e992b2b..a692b1f1 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,12 +1,12 @@ -# User.all.destroy +# Customer.all.destroy # Inventory.all.destroy # Item.all.destroy # Purchase.all.destroy # Store.all.destroy -alex = User.create(name: "Alex", current_location: "1440 G St. NW, Washington DC 20001") -truce = User.create(name: "Truce", current_location: "60008 Franklin square, Washington D.C. 20015") -bode = User.create(name: "Bode", current_location: "5959 Dublin street, Washington D.C. 20033") +alex = Customer.create(name: "Alex", current_location: "1440 G St. NW, Washington DC 20001") +truce = Customer.create(name: "Truce", current_location: "60008 Franklin square, Washington D.C. 20015") +bode = Customer.create(name: "Bode", current_location: "5959 Dublin street, Washington D.C. 20033") shoppers = Store.create(name: "Shoppers World", address: "1259 Washington Boulevard, D.C. 20002") walmart = Store.create(name: "Walmart", address: "5288 Mushin street, D.C. 20019") diff --git a/lib/Users.rb b/lib/Customers.rb similarity index 65% rename from lib/Users.rb rename to lib/Customers.rb index 2928278d..b4aa2674 100644 --- a/lib/Users.rb +++ b/lib/Customers.rb @@ -1,4 +1,4 @@ -class User < ActiveRecord::Base +class Customer < ActiveRecord::Base has_many :purchases has_many :items, through: :purchases end \ No newline at end of file diff --git a/lib/Items.rb b/lib/Items.rb index a82f6e70..cef47fce 100644 --- a/lib/Items.rb +++ b/lib/Items.rb @@ -2,5 +2,5 @@ class Item < ActiveRecord::Base has_many :inventories has_many :stores, through: :inventories has_many :purchases - has_many :users, through: :purchases + has_many :customers, through: :purchases end \ No newline at end of file diff --git a/lib/Purchase.rb b/lib/Purchase.rb index 0a6af65d..343a0034 100644 --- a/lib/Purchase.rb +++ b/lib/Purchase.rb @@ -1,4 +1,4 @@ class Purchase < ActiveRecord::Base belongs_to :item - belongs_to :user + belongs_to :customer end \ No newline at end of file From d2b240718a09fc79c65ff566ae5111508f98d53c Mon Sep 17 00:00:00 2001 From: woolosh Date: Thu, 28 Jan 2021 17:17:27 -0600 Subject: [PATCH 8/8] seed files added --- bin/run.rb | 1 + db/seeds.rb | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bin/run.rb b/bin/run.rb index cf08c338..422417e6 100644 --- a/bin/run.rb +++ b/bin/run.rb @@ -3,3 +3,4 @@ puts "HELLO WORLD" +puts "Please enter" diff --git a/db/seeds.rb b/db/seeds.rb index a692b1f1..07faf6fc 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -8,11 +8,20 @@ truce = Customer.create(name: "Truce", current_location: "60008 Franklin square, Washington D.C. 20015") bode = Customer.create(name: "Bode", current_location: "5959 Dublin street, Washington D.C. 20033") -shoppers = Store.create(name: "Shoppers World", address: "1259 Washington Boulevard, D.C. 20002") -walmart = Store.create(name: "Walmart", address: "5288 Mushin street, D.C. 20019") -costco = Store.create(name: "Costco", address: "5 Oily way, Washington D.C. 20012") +shoppers = Store.create(name: "Shoppers World", address: "1259 Washington Boulevard, Washington, D.C. 20002") +bargain = Store.create(name: "Bargain Shopper", address: "625 Bargain St, Washington, D.C. 20002") +wallys = Store.create(name: "Wally's", address: "131 Alamo St, Washington, D.C. 20002") +costco = Store.create(name: "Costco", address: "5 Oily way, Washington, D.C. 20012") +boscos = Store.create(name: "Bosco's", address: "12 Union Blvd, Washington, D.C. 20012") +kroger = Store.create(name: "Kroger", address: "4000 Washington Boulevard, Washington, D.C. 20012") +heb = Store.create(name: "H-E-B", address: "525 Williams Way, Washington, D.C. 20012") +walmart = Store.create(name: "Walmart", address: "5288 Mushin Street, Washington, D.C. 20019") -bread = Item.create(name:'Bread') -sweetnsour = Item.create(name:'Sweet N Sour') -mixed_nuts = Item.create(name: "Mixed Nuts - salted") \ No newline at end of file +bread = Item.create(name:'Bread', qty: 1) +sweetnsour = Item.create(name:'Sweet N Sour', qty: 1) +mixed_nuts = Item.create(name: "Mixed Nuts - salted", qty: 2) +milk = Item.create(name: "Milk", qty: 1) +chips = Item.create(name: "Doritos", qty: 2) +chili = Item.create(name: "Wolf Brand Chili", qty: 3) +crackers = Item.create(name: "M")