diff --git a/Gemfile b/Gemfile index 23d08f55edea23a1601f7b8d841ba177ee3d54ab..99d787db7e8184ca4f67704b87903f2f46176963 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby '2.7.2' +ruby '2.5.8' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.4', '>= 5.2.4.4' diff --git a/db/migrate/20201112235113_create_tables.rb b/db/migrate/20201112235113_create_tables.rb index bc1ea27cac29e63159650cfe7b9def943c19fbe2..9a3004a681aeb0144dbea5ea86bdb4ee9521acac 100644 --- a/db/migrate/20201112235113_create_tables.rb +++ b/db/migrate/20201112235113_create_tables.rb @@ -1,6 +1,6 @@ class CreateTables < ActiveRecord::Migration[5.2] def change - create_table :users, index: true do |t| + create_table :users, index: true do |t| # Users table t.string :email, null: false, unique: true t.string :name, null: false t.string :password, null: false @@ -8,14 +8,14 @@ class CreateTables < ActiveRecord::Migration[5.2] t.timestamps end - create_table :lists, index: true do |t| + create_table :lists, index: true do |t| # Lists table t.string :name, null: false, unique: true t.belongs_to :user, foreign_key: true, null: false, index: false t.timestamps end - create_table :products, index: true do |t| + create_table :products, index: true do |t| # Products table t.string :name, null: false t.integer :quantity t.boolean :acquired, null: false diff --git a/db/seeds.rb b/db/seeds.rb index 4873736a1d685c303b96fb2c0c8afe3866fdc418..b8c4176f9a6add389a1f73b4895197643338fa65 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -6,8 +6,45 @@ # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) -User.create(email: '123@gmail.com', name: 'Kieran', password: 'pass') -List.create(name: 'asda', user_id: 1) -@p = Product.create(name: 'food', acquired: 0, list_id: 1) +# Clear all previous data from database +User.destroy_all -puts @p.inspect \ No newline at end of file +# Create Users +kieran = User.create(email: 'kieran@gmail.com', name: 'Kieran', password: 'pass1') +brandon = User.create(email: 'brandon@gmail.com', name: 'Brandon', password: 'pass2') +lerissa = User.create(email: 'lerissa@gmail.com', name: 'Lerissa', password: 'pass3') + +# Create Lists +gear = List.create(name: 'Climbing Gear', user_id: kieran.id) +programs = List.create(name: 'Programs', user_id: kieran.id) + +shoes = List.create(name: 'Shoes', user_id: brandon.id) +skate = List.create(name: 'Skateboard Stuff', user_id: brandon.id) + +pens = List.create(name: 'Pens', user_id: lerissa.id) +ingredients = List.create(name: 'Baking Ingredients', user_id: lerissa.id) + +# Create Products +Product.create(name: 'Chalk', quantity: 2, acquired: 1, list_id: gear.id) +Product.create(name: 'Shoes', quantity: 1, acquired: 1, list_id: gear.id) +Product.create(name: 'Quick draws', quantity: 10, acquired: 0, list_id: gear.id) + +Product.create(name: 'RubyMine', quantity: 1, acquired: 1, list_id: programs.id) +Product.create(name: 'FlStudio', quantity: 1, acquired: 1, list_id: programs.id) +Product.create(name: 'Photoshop', quantity: 1, acquired: 0, list_id: programs.id) + +Product.create(name: 'Air Force 1', quantity: 1, acquired: 1, list_id: shoes.id) +Product.create(name: 'Yeezy Boost', quantity: 1, acquired: 0, list_id: shoes.id) +Product.create(name: 'Kyrie 4', quantity: 1, acquired: 1, list_id: shoes.id) + +Product.create(name: 'Wheel', quantity: 4, acquired: 1, list_id: skate.id) +Product.create(name: 'Griptape', quantity: 1, acquired: 1, list_id: skate.id) +Product.create(name: 'Skate Tool', quantity: 1, acquired: 0, list_id: skate.id) + +Product.create(name: 'Crayola', quantity: 30, acquired: 1, list_id: pens.id) +Product.create(name: 'Bic', quantity: 3, acquired: 0, list_id: pens.id) +Product.create(name: 'PaperMate', quantity: 5, acquired: 1, list_id: pens.id) + +Product.create(name: 'Flour', quantity: 2, acquired: 1, list_id: ingredients.id) +Product.create(name: 'Banana', quantity: 3, acquired: 0, list_id: ingredients.id) +Product.create(name: 'Icing Sheet', quantity: 1, acquired: 0, list_id: ingredients.id)