Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 33 additions & 34 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -53,4 +52,4 @@ DEPENDENCIES
sqlite3

BUNDLED WITH
1.14.6
1.17.3
1 change: 1 addition & 0 deletions bin/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@


puts "HELLO WORLD"
puts "Please enter"
Empty file.
12 changes: 12 additions & 0 deletions db/migrate/20210127191926_create_inventory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateInventory < ActiveRecord::Migration[6.1]
def change
create_table :inventories do
|t|
t.references :store
t.references :item
t.float :price
t.integer :quantity
t.timestamps
end
end
end
9 changes: 9 additions & 0 deletions db/migrate/20210127192037_create_items.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateItems < ActiveRecord::Migration[6.1]
def change
create_table :items do
|t|
t.string :name
t.timestamps
end
end
end
10 changes: 10 additions & 0 deletions db/migrate/20210127192047_create_purchase.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreatePurchase < ActiveRecord::Migration[6.1]
def change
create_table :purchases do
|t|
t.references :item
t.references :customer
t.timestamps
end
end
end
10 changes: 10 additions & 0 deletions db/migrate/20210127192055_create_stores.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateStores < ActiveRecord::Migration[6.1]
def change
create_table :stores do
|t|
t.string :name
t.string :address
t.timestamps
end
end
end
10 changes: 10 additions & 0 deletions db/migrate/20210127192100_create_customers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateCustomers < ActiveRecord::Migration[6.1]
def change
create_table :customers do
|t|
t.string :name
t.string :current_location
t.timestamps
end
end
end
55 changes: 55 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -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 "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"
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 ["store_id"], name: "index_inventories_on_store_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 "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"
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

end
27 changes: 27 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Customer.all.destroy
# Inventory.all.destroy
# Item.all.destroy
# Purchase.all.destroy
# Store.all.destroy

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, 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', 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")
4 changes: 4 additions & 0 deletions lib/Customers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Customer < ActiveRecord::Base
has_many :purchases
has_many :items, through: :purchases
end
4 changes: 4 additions & 0 deletions lib/Inventory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Inventory < ActiveRecord::Base
belongs_to :store
belongs_to :item
end
6 changes: 6 additions & 0 deletions lib/Items.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Item < ActiveRecord::Base
has_many :inventories
has_many :stores, through: :inventories
has_many :purchases
has_many :customers, through: :purchases
end
4 changes: 4 additions & 0 deletions lib/Purchase.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Purchase < ActiveRecord::Base
belongs_to :item
belongs_to :customer
end
4 changes: 4 additions & 0 deletions lib/Stores.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Store < ActiveRecord::Base
has_many :inventories
has_many :items, through: :inventories
end
2 changes: 2 additions & 0 deletions lib/User.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class User < ActiveRecord::Base
end
5 changes: 5 additions & 0 deletions lib/concerns/Instance_method_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class InstanceMethodHelper
def zip
address.split.last.to_i
end
end