From a0d2dcecbabbf54315bd5769083a8ff52d38bf4b Mon Sep 17 00:00:00 2001 From: github username Date: Mon, 8 Mar 2021 14:29:43 -0600 Subject: [PATCH 01/25] initial commit with project setup --- Gemfile.lock | 69 +++++++++++----------- db/migrate/20210308201358_create_guests.rb | 4 ++ db/seeds.rb | 0 3 files changed, 38 insertions(+), 35 deletions(-) create mode 100644 db/migrate/20210308201358_create_guests.rb create mode 100644 db/seeds.rb diff --git a/Gemfile.lock b/Gemfile.lock index 9589226d..677b166c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,50 +1,49 @@ 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.3) + activesupport (= 6.1.3) + activerecord (6.1.3) + activemodel (= 6.1.3) + activesupport (= 6.1.3) + activesupport (6.1.3) 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.9) 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.4) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + pry (0.14.0) + 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 + x86_64-darwin-20 DEPENDENCIES pry @@ -53,4 +52,4 @@ DEPENDENCIES sqlite3 BUNDLED WITH - 1.14.6 + 2.2.13 diff --git a/db/migrate/20210308201358_create_guests.rb b/db/migrate/20210308201358_create_guests.rb new file mode 100644 index 00000000..0585d66e --- /dev/null +++ b/db/migrate/20210308201358_create_guests.rb @@ -0,0 +1,4 @@ +class CreateGuests < ActiveRecord::Migration[6.1] + def change + end +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 00000000..e69de29b From da980234673f5183480ee27bddc15bdecca1f1a0 Mon Sep 17 00:00:00 2001 From: github username Date: Mon, 8 Mar 2021 17:23:32 -0600 Subject: [PATCH 02/25] migrated models and created tables --- app/models/guest.rb | 2 + app/models/theater.rb | 0 bin/{run.rb => program.rb} | 3 +- config/environment.rb | 8 +++- db/development.sqlite | 0 db/migrate/20210308201358_create_guests.rb | 5 +++ db/migrate/20210308205332_create_theaters.rb | 9 ++++ db/migrate/20210308205351_create_genres.rb | 7 +++ db/migrate/20210308205403_create_movies.rb | 9 ++++ .../20210308205440_create_ticketpurchases.rb | 11 +++++ db/schema.rb | 43 +++++++++++++++++++ db/seeds.rb | 5 +++ 12 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 app/models/guest.rb create mode 100644 app/models/theater.rb rename bin/{run.rb => program.rb} (68%) create mode 100644 db/development.sqlite create mode 100644 db/migrate/20210308205332_create_theaters.rb create mode 100644 db/migrate/20210308205351_create_genres.rb create mode 100644 db/migrate/20210308205403_create_movies.rb create mode 100644 db/migrate/20210308205440_create_ticketpurchases.rb create mode 100644 db/schema.rb diff --git a/app/models/guest.rb b/app/models/guest.rb new file mode 100644 index 00000000..99aba379 --- /dev/null +++ b/app/models/guest.rb @@ -0,0 +1,2 @@ +class Guest < ActiveRecord::Base +end diff --git a/app/models/theater.rb b/app/models/theater.rb new file mode 100644 index 00000000..e69de29b diff --git a/bin/run.rb b/bin/program.rb similarity index 68% rename from bin/run.rb rename to bin/program.rb index cf08c338..204ce571 100644 --- a/bin/run.rb +++ b/bin/program.rb @@ -1,5 +1,6 @@ +require 'pry' require_relative '../config/environment' - +# binding.pry puts "HELLO WORLD" diff --git a/config/environment.rb b/config/environment.rb index 4dbe13e5..92ed3339 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,5 +1,9 @@ require 'bundler' Bundler.require -ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') -require_all 'lib' +ActiveRecord::Base.establish_connection( + :adapter => "sqlite3", + :database => "db/development.sqlite" +) + +require_all 'app' diff --git a/db/development.sqlite b/db/development.sqlite new file mode 100644 index 00000000..e69de29b diff --git a/db/migrate/20210308201358_create_guests.rb b/db/migrate/20210308201358_create_guests.rb index 0585d66e..9182d453 100644 --- a/db/migrate/20210308201358_create_guests.rb +++ b/db/migrate/20210308201358_create_guests.rb @@ -1,4 +1,9 @@ class CreateGuests < ActiveRecord::Migration[6.1] + def change + create_table :guests do |t| + t.string :name + t.integer :age + end end end diff --git a/db/migrate/20210308205332_create_theaters.rb b/db/migrate/20210308205332_create_theaters.rb new file mode 100644 index 00000000..28d964de --- /dev/null +++ b/db/migrate/20210308205332_create_theaters.rb @@ -0,0 +1,9 @@ +class CreateTheaters < ActiveRecord::Migration[6.1] + def change + create_table :theaters do |t| + t.string :name + t.string :viewing_room + # t.integer :seats + end + end +end diff --git a/db/migrate/20210308205351_create_genres.rb b/db/migrate/20210308205351_create_genres.rb new file mode 100644 index 00000000..c4b1b1ce --- /dev/null +++ b/db/migrate/20210308205351_create_genres.rb @@ -0,0 +1,7 @@ +class CreateGenres < ActiveRecord::Migration[6.1] + def change + create_table :genres do |t| + t.string :genre + end + end +end diff --git a/db/migrate/20210308205403_create_movies.rb b/db/migrate/20210308205403_create_movies.rb new file mode 100644 index 00000000..5cd3d625 --- /dev/null +++ b/db/migrate/20210308205403_create_movies.rb @@ -0,0 +1,9 @@ +class CreateMovies < ActiveRecord::Migration[6.1] + def change + create_table :movies do |t| + t.string :title + t.integer :showtime + t.integer :age_rating + end + end +end diff --git a/db/migrate/20210308205440_create_ticketpurchases.rb b/db/migrate/20210308205440_create_ticketpurchases.rb new file mode 100644 index 00000000..a7c2baf0 --- /dev/null +++ b/db/migrate/20210308205440_create_ticketpurchases.rb @@ -0,0 +1,11 @@ +class CreateTicketpurchases < ActiveRecord::Migration[6.1] + def change + create_table :ticketpurchases do |t| + t.integer :guest_id + t.string :viewing_room + t.integer :movie_id + t.integer :showtime + t.integer :ticket_price + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 00000000..5cc751a5 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,43 @@ +# 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_03_08_205440) do + + create_table "genres", force: :cascade do |t| + t.string "genre" + end + + create_table "guests", force: :cascade do |t| + t.string "name" + t.integer "age" + end + + create_table "movies", force: :cascade do |t| + t.string "title" + t.integer "showtime" + t.integer "age_rating" + end + + create_table "theaters", force: :cascade do |t| + t.string "name" + t.string "viewing_room" + end + + create_table "ticketpurchases", force: :cascade do |t| + t.string "guest_id" + t.string "viewing_room" + t.string "movie_id" + t.integer "showtime" + t.integer "ticket_price" + end + +end diff --git a/db/seeds.rb b/db/seeds.rb index e69de29b..b4c32ce4 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -0,0 +1,5 @@ +# require_relative './config/environment.rb' + +Guest.destroy_all + +g1 = Guest.create(name: "Hadi", age: 28) \ No newline at end of file From 08d4802fbc24511084a3d44ee47f35f4d2f8c60e Mon Sep 17 00:00:00 2001 From: github username Date: Tue, 9 Mar 2021 16:51:46 -0600 Subject: [PATCH 03/25] created all tables --- Gemfile.lock | 69 +++++++++---------- apps/models/movie.rb | 2 + config/database.yml | 2 +- config/environment.rb | 2 +- .../20210309224256_create_movies_table.rb | 10 +++ .../20210309224721_create_theaters_table.rb | 7 ++ .../20210309224824_create_genres_table.rb | 7 ++ .../20210309224916_create_guests_table.rb | 7 ++ .../20210309225013_create_tickets_table.rb | 9 +++ db/schema.rb | 40 +++++++++++ db/seeds.rb | 1 + 11 files changed, 119 insertions(+), 37 deletions(-) create mode 100644 apps/models/movie.rb create mode 100644 db/migrate/20210309224256_create_movies_table.rb create mode 100644 db/migrate/20210309224721_create_theaters_table.rb create mode 100644 db/migrate/20210309224824_create_genres_table.rb create mode 100644 db/migrate/20210309224916_create_guests_table.rb create mode 100644 db/migrate/20210309225013_create_tickets_table.rb create mode 100644 db/schema.rb create mode 100644 db/seeds.rb diff --git a/Gemfile.lock b/Gemfile.lock index 9589226d..677b166c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,50 +1,49 @@ 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.3) + activesupport (= 6.1.3) + activerecord (6.1.3) + activemodel (= 6.1.3) + activesupport (= 6.1.3) + activesupport (6.1.3) 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.9) 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.4) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + pry (0.14.0) + 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 + x86_64-darwin-20 DEPENDENCIES pry @@ -53,4 +52,4 @@ DEPENDENCIES sqlite3 BUNDLED WITH - 1.14.6 + 2.2.13 diff --git a/apps/models/movie.rb b/apps/models/movie.rb new file mode 100644 index 00000000..49198a7d --- /dev/null +++ b/apps/models/movie.rb @@ -0,0 +1,2 @@ +class Movie < ActiveRecord::Base +end diff --git a/config/database.yml b/config/database.yml index 31199e77..6390bff1 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,5 +1,5 @@ development: adapter: sqlite3 - database: db/development.db + database: db/development.db pool: 5 timeout: 5000 diff --git a/config/environment.rb b/config/environment.rb index 4dbe13e5..e1a6e4eb 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -2,4 +2,4 @@ Bundler.require ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') -require_all 'lib' +require_all 'apps' diff --git a/db/migrate/20210309224256_create_movies_table.rb b/db/migrate/20210309224256_create_movies_table.rb new file mode 100644 index 00000000..08d8164d --- /dev/null +++ b/db/migrate/20210309224256_create_movies_table.rb @@ -0,0 +1,10 @@ +class CreateMoviesTable < ActiveRecord::Migration[6.1] + def change + create_table :movies do |t| + t.string :title + t.string :genre + t.integer :showtime + t.string :theater + end + end +end diff --git a/db/migrate/20210309224721_create_theaters_table.rb b/db/migrate/20210309224721_create_theaters_table.rb new file mode 100644 index 00000000..f642a71b --- /dev/null +++ b/db/migrate/20210309224721_create_theaters_table.rb @@ -0,0 +1,7 @@ +class CreateTheatersTable < ActiveRecord::Migration[6.1] + def change + create_table :theaters do |t| + t.string :name + end + end +end diff --git a/db/migrate/20210309224824_create_genres_table.rb b/db/migrate/20210309224824_create_genres_table.rb new file mode 100644 index 00000000..b81537f1 --- /dev/null +++ b/db/migrate/20210309224824_create_genres_table.rb @@ -0,0 +1,7 @@ +class CreateGenresTable < ActiveRecord::Migration[6.1] + def change + create_table :genres do |t| + t.string :genre + end + end +end diff --git a/db/migrate/20210309224916_create_guests_table.rb b/db/migrate/20210309224916_create_guests_table.rb new file mode 100644 index 00000000..244c3e53 --- /dev/null +++ b/db/migrate/20210309224916_create_guests_table.rb @@ -0,0 +1,7 @@ +class CreateGuestsTable < ActiveRecord::Migration[6.1] + def change + create_table :guests do |t| + t.string :name + end + end +end diff --git a/db/migrate/20210309225013_create_tickets_table.rb b/db/migrate/20210309225013_create_tickets_table.rb new file mode 100644 index 00000000..c4ca2ddc --- /dev/null +++ b/db/migrate/20210309225013_create_tickets_table.rb @@ -0,0 +1,9 @@ +class CreateTicketsTable < ActiveRecord::Migration[6.1] + def change + create_table :tickets do |t| + t.string :theater + t.string :movie + t.string :guest + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 00000000..9832a4a9 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,40 @@ +# 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_03_09_225013) do + + create_table "genres", force: :cascade do |t| + t.string "genre" + end + + create_table "guests", force: :cascade do |t| + t.string "name" + end + + create_table "movies", force: :cascade do |t| + t.string "title" + t.string "genre" + t.integer "showtime" + t.string "theater" + end + + create_table "theaters", force: :cascade do |t| + t.string "name" + end + + create_table "tickets", force: :cascade do |t| + t.string "theater" + t.string "movie" + t.string "guest" + end + +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 00000000..3ad2e7d4 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1 @@ +m1 = Movie.create(title: "ddd", genre: "drama", showtime: 6, theater: "aaa") \ No newline at end of file From 1530ba0aa9e6ddec99bb3cbd4430a52f15eaef4b Mon Sep 17 00:00:00 2001 From: hadi Date: Tue, 9 Mar 2021 16:59:54 -0600 Subject: [PATCH 04/25] initial commit-new --- Gemfile.lock | 67 +++++++++++++++++++++--------------------- apps/models/genre.rb | 2 ++ apps/models/guest.rb | 2 ++ apps/models/movie.rb | 2 ++ apps/models/theater.rb | 2 ++ config/database.yml | 2 +- config/environment.rb | 2 +- db/seeds.rb | 1 + 8 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 apps/models/genre.rb create mode 100644 apps/models/guest.rb create mode 100644 apps/models/movie.rb create mode 100644 apps/models/theater.rb create mode 100644 db/seeds.rb diff --git a/Gemfile.lock b/Gemfile.lock index 9589226d..edb99ee2 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.3) + activesupport (= 6.1.3) + activerecord (6.1.3) + activemodel (= 6.1.3) + activesupport (= 6.1.3) + activesupport (6.1.3) 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.9) 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.4) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + pry (0.14.0) + 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/apps/models/genre.rb b/apps/models/genre.rb new file mode 100644 index 00000000..a02f9f11 --- /dev/null +++ b/apps/models/genre.rb @@ -0,0 +1,2 @@ +class Genre < ActiveRecord::Base +end \ No newline at end of file diff --git a/apps/models/guest.rb b/apps/models/guest.rb new file mode 100644 index 00000000..b0c161a9 --- /dev/null +++ b/apps/models/guest.rb @@ -0,0 +1,2 @@ +class Guest < ActiveRecord::Base +end \ No newline at end of file diff --git a/apps/models/movie.rb b/apps/models/movie.rb new file mode 100644 index 00000000..9fc7d52e --- /dev/null +++ b/apps/models/movie.rb @@ -0,0 +1,2 @@ +class Movie < ActiveRecord::Base +end \ No newline at end of file diff --git a/apps/models/theater.rb b/apps/models/theater.rb new file mode 100644 index 00000000..c3507e59 --- /dev/null +++ b/apps/models/theater.rb @@ -0,0 +1,2 @@ +class Theater < ActiveRecord::Base +end diff --git a/config/database.yml b/config/database.yml index 31199e77..6390bff1 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,5 +1,5 @@ development: adapter: sqlite3 - database: db/development.db + database: db/development.db pool: 5 timeout: 5000 diff --git a/config/environment.rb b/config/environment.rb index 4dbe13e5..e1a6e4eb 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -2,4 +2,4 @@ Bundler.require ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') -require_all 'lib' +require_all 'apps' diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 00000000..e106118d --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1 @@ +t1=Theater.create(name: "donovan") \ No newline at end of file From 3248c0e414ce33b99a62b4ca12fffa62335a05a8 Mon Sep 17 00:00:00 2001 From: github username Date: Tue, 9 Mar 2021 17:33:34 -0600 Subject: [PATCH 05/25] small --- db/seeds.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 1181b03a..9dabb05e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,6 +1,4 @@ -<<<<<<< HEAD + t1=Theater.create(name: "donovan") -======= -m1 = Movie.create(title: "ddd", genre: "drama", showtime: 6, theater: "aaa") ->>>>>>> f95df87a034e71bbfa90751e78d0d823119441dd +m1 = Movie.create(title: "ddd", genre: "drama", showtime: 6, theater: "aaa") From c586e27c0cbbf9ba4d986e6af264edb1ca8a576b Mon Sep 17 00:00:00 2001 From: github username Date: Wed, 10 Mar 2021 09:36:42 -0600 Subject: [PATCH 06/25] seed file populated --- db/seeds.rb | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 9dabb05e..46b18152 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,4 +1,49 @@ -t1=Theater.create(name: "donovan") +rom_com=Genre.create("Romantic Comedy") +action=Genre.create("Action") +sci_fi=Genre.create("Science Fiction") +slasher=Genre.create("Slasher") -m1 = Movie.create(title: "ddd", genre: "drama", showtime: 6, theater: "aaa") +g1=Guest.create("Hadi") +g2=Guest.create("Donovan") +g3=Guest.create("Drake") +g4=Guest.create("Sonny") +g5=Guest.create("Shrek") +g6=Guest.create("Neo") +g7=Guest.create("Trinity") +g8=Guest.create("P.Rudd") +g9=Guest.create("Jackie Chan") +g10=Guest.create("Bagheera") + +m1 = Movie.create(title: "Groundhog Day", genre: "rom_com", showtime: 6, theater: "Commando Theater") +m2 = Movie.create(title: "Clueless", genre: "rom_com", showtime: 3, theater: "Commando Theater") +m3 = Movie.create(title: "Sleepless in Seattle", genre: "rom_com", showtime: 11, theater: "Commando Theater") +m4 = Movie.create(title: "Rush Hour", genre: "action", showtime: 4, theater: "Commando Theater") +m5 = Movie.create(title: "The Matrix", genre: "action", showtime: 12, theater: "Commando Theater") +m6 = Movie.create(title: "Inside Man", genre: "action", showtime: 6, theater: "Commando Theater") +m7 = Movie.create(title: "Mars Attacks", genre: "sci_fi", showtime: 9, theater: "Commando Theater") +m8 = Movie.create(title: "Predator", genre: "sci_fi", showtime: 12, theater: "Commando Theater") +m9 = Movie.create(title: "Jurassic Park", genre: "sci_fi", showtime: 4, theater: "Commando Theater") +m10 = Movie.create(title: "I Know What You Did Last Summer", genre: "slasher", showtime: 11, theater: "Commando Theater") +m11 = Movie.create(title: "Scream", genre: "slasher", showtime: 12, theater: "Commando Theater") +m12 = Movie.create(title: "Halloween", genre: "slasher", showtime: 10, theater: "Commando Theater") + +commando=Theater.create(name: "Commando Theater") + +t1=Ticket.create(theater: "Commando Theater", movie: "Groundhog Day", guest: "Bagheera") +t2=Ticket.create(theater: "Commando Theater", movie: "Clueless", guest: "Bagheera") +t3=Ticket.create(theater: "Commando Theater", movie: "Sleepless in Seattle", guest: "Bagheera") +t4=Ticket.create(theater: "Commando Theater", movie: "Rush Hour", guest: "Bagheera") +t5=Ticket.create(theater: "Commando Theater", movie: "The Matrix", guest: "Bagheera") +t6=Ticket.create(theater: "Commando Theater", movie: "Inside Man", guest: "Bagheera") +t7=Ticket.create(theater: "Commando Theater", movie: "Mars Attacks", guest: "Bagheera") +t8=Ticket.create(theater: "Commando Theater", movie: "Predator", guest: "Bagheera") +t9=Ticket.create(theater: "Commando Theater", movie: "Jurassic Park", guest: "Bagheera") +t10=Ticket.create(theater: "Commando Theater", movie: "I Know What You Did Last Summer", guest: "Bagheera") +t11=Ticket.create(theater: "Commando Theater", movie: "Scream", guest: "Bagheera") +t12=Ticket.create(theater: "Commando Theater", movie: "Halloween", guest: "Bagheera") +t13=Ticket.create(theater: "Commando Theater", movie: "Clueless", guest: "Bagheera") +t14=Ticket.create(theater: "Commando Theater", movie: "Clueless", guest: "Bagheera") +t15=Ticket.create(theater: "Commando Theater", movie: "Rush Hour", guest: "Bagheera") +t16=Ticket.create(theater: "Commando Theater", movie: "Jurassic Park", guest: "Bagheera") +t17=Ticket.create(theater: "Commando Theater", movie: "Scream", guest: "Bagheera") From 91aae33e228ea81bd9778c209839546b714a6c3a Mon Sep 17 00:00:00 2001 From: hadi Date: Wed, 10 Mar 2021 09:51:15 -0600 Subject: [PATCH 07/25] adds many to many --- apps/models/genre.rb | 1 + apps/models/guest.rb | 1 + apps/models/movie.rb | 3 +++ apps/models/theater.rb | 1 + apps/models/ticket.rb | 3 +++ 5 files changed, 9 insertions(+) create mode 100644 apps/models/ticket.rb diff --git a/apps/models/genre.rb b/apps/models/genre.rb index a02f9f11..51c4327b 100644 --- a/apps/models/genre.rb +++ b/apps/models/genre.rb @@ -1,2 +1,3 @@ class Genre < ActiveRecord::Base + has_many :movie end \ No newline at end of file diff --git a/apps/models/guest.rb b/apps/models/guest.rb index b0c161a9..2ba172d7 100644 --- a/apps/models/guest.rb +++ b/apps/models/guest.rb @@ -1,2 +1,3 @@ class Guest < ActiveRecord::Base + has_many :ticket end \ No newline at end of file diff --git a/apps/models/movie.rb b/apps/models/movie.rb index 49198a7d..f14a3d7f 100644 --- a/apps/models/movie.rb +++ b/apps/models/movie.rb @@ -1,2 +1,5 @@ class Movie < ActiveRecord::Base + belongs_to :theater + #has_many :genre ????????????????????????????? + end diff --git a/apps/models/theater.rb b/apps/models/theater.rb index c3507e59..37bcf5b7 100644 --- a/apps/models/theater.rb +++ b/apps/models/theater.rb @@ -1,2 +1,3 @@ class Theater < ActiveRecord::Base + has_many :guest :through :ticket end diff --git a/apps/models/ticket.rb b/apps/models/ticket.rb new file mode 100644 index 00000000..cda88590 --- /dev/null +++ b/apps/models/ticket.rb @@ -0,0 +1,3 @@ +class Ticket < ActiveRecord::Base + belongs_to :guest +end From c88a69ac222de287a26517f14eb6db2dff9f5188 Mon Sep 17 00:00:00 2001 From: github username Date: Wed, 10 Mar 2021 10:55:37 -0600 Subject: [PATCH 08/25] fixed_associations_and_columns_to_accept_ids --- Gemfile.lock | 1 + apps/models/genre.rb | 2 +- apps/models/guest.rb | 2 +- apps/models/movie.rb | 3 +- apps/models/theater.rb | 2 +- apps/models/ticket.rb | 2 +- ...change_movie_table_column_to_accept_ids.rb | 6 ++ ...24_changing_table_columns_to_accept_ids.rb | 13 +++ db/schema.rb | 12 +-- db/seeds.rb | 94 ++++++++++--------- 10 files changed, 81 insertions(+), 56 deletions(-) create mode 100644 db/migrate/20210310162854_change_movie_table_column_to_accept_ids.rb create mode 100644 db/migrate/20210310163524_changing_table_columns_to_accept_ids.rb diff --git a/Gemfile.lock b/Gemfile.lock index ba22fa03..511c4a10 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,6 +43,7 @@ GEM zeitwerk (2.4.2) PLATFORMS + x86_64-darwin-20 x86_64-linux DEPENDENCIES diff --git a/apps/models/genre.rb b/apps/models/genre.rb index 51c4327b..9251ae53 100644 --- a/apps/models/genre.rb +++ b/apps/models/genre.rb @@ -1,3 +1,3 @@ class Genre < ActiveRecord::Base - has_many :movie + has_many :movies end \ No newline at end of file diff --git a/apps/models/guest.rb b/apps/models/guest.rb index 2ba172d7..cac6aa4c 100644 --- a/apps/models/guest.rb +++ b/apps/models/guest.rb @@ -1,3 +1,3 @@ class Guest < ActiveRecord::Base - has_many :ticket + has_many :tickets end \ No newline at end of file diff --git a/apps/models/movie.rb b/apps/models/movie.rb index f14a3d7f..1395b210 100644 --- a/apps/models/movie.rb +++ b/apps/models/movie.rb @@ -1,5 +1,4 @@ class Movie < ActiveRecord::Base belongs_to :theater - #has_many :genre ????????????????????????????? - + end diff --git a/apps/models/theater.rb b/apps/models/theater.rb index 37bcf5b7..a31a89c8 100644 --- a/apps/models/theater.rb +++ b/apps/models/theater.rb @@ -1,3 +1,3 @@ class Theater < ActiveRecord::Base - has_many :guest :through :ticket + has_many :tickets end diff --git a/apps/models/ticket.rb b/apps/models/ticket.rb index cda88590..7da03b2e 100644 --- a/apps/models/ticket.rb +++ b/apps/models/ticket.rb @@ -1,3 +1,3 @@ class Ticket < ActiveRecord::Base - belongs_to :guest + belongs_to :guest end diff --git a/db/migrate/20210310162854_change_movie_table_column_to_accept_ids.rb b/db/migrate/20210310162854_change_movie_table_column_to_accept_ids.rb new file mode 100644 index 00000000..82b871eb --- /dev/null +++ b/db/migrate/20210310162854_change_movie_table_column_to_accept_ids.rb @@ -0,0 +1,6 @@ +class ChangeMovieTableColumnToAcceptIds < ActiveRecord::Migration[6.1] + def change + rename_column(:movies, :genre, :genre_id) + change_column(:movies, :genre_id, :integer) + end +end diff --git a/db/migrate/20210310163524_changing_table_columns_to_accept_ids.rb b/db/migrate/20210310163524_changing_table_columns_to_accept_ids.rb new file mode 100644 index 00000000..78da5309 --- /dev/null +++ b/db/migrate/20210310163524_changing_table_columns_to_accept_ids.rb @@ -0,0 +1,13 @@ +class ChangingTableColumnsToAcceptIds < ActiveRecord::Migration[6.1] + def change + rename_column(:movies, :theater, :theater_id) + change_column(:movies, :theater_id, :integer) + rename_column(:tickets, :theater, :theater_id) + rename_column(:tickets, :movie, :movie_id) + rename_column(:tickets, :guest, :guest_id) + change_column(:tickets, :theater_id, :integer) + change_column(:tickets, :movie_id, :integer) + change_column(:tickets, :guest_id, :integer) + + end +end diff --git a/db/schema.rb b/db/schema.rb index 9832a4a9..c227f4e8 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.define(version: 2021_03_09_225013) do +ActiveRecord::Schema.define(version: 2021_03_10_163524) do create_table "genres", force: :cascade do |t| t.string "genre" @@ -22,9 +22,9 @@ create_table "movies", force: :cascade do |t| t.string "title" - t.string "genre" + t.integer "genre_id" t.integer "showtime" - t.string "theater" + t.integer "theater_id" end create_table "theaters", force: :cascade do |t| @@ -32,9 +32,9 @@ end create_table "tickets", force: :cascade do |t| - t.string "theater" - t.string "movie" - t.string "guest" + t.integer "theater_id" + t.integer "movie_id" + t.integer "guest_id" end end diff --git a/db/seeds.rb b/db/seeds.rb index 46b18152..592c2e07 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,49 +1,55 @@ +Theater.destroy_all +Guest.destroy_all +Genre.destroy_all +Movie.destroy_all +Ticket.destroy_all -rom_com=Genre.create("Romantic Comedy") -action=Genre.create("Action") -sci_fi=Genre.create("Science Fiction") -slasher=Genre.create("Slasher") +commando=Theater.create(name: "Commando Theater") -g1=Guest.create("Hadi") -g2=Guest.create("Donovan") -g3=Guest.create("Drake") -g4=Guest.create("Sonny") -g5=Guest.create("Shrek") -g6=Guest.create("Neo") -g7=Guest.create("Trinity") -g8=Guest.create("P.Rudd") -g9=Guest.create("Jackie Chan") -g10=Guest.create("Bagheera") +rom_com=Genre.create(genre: "Romantic Comedy") +action=Genre.create(genre: "Action") +sci_fi=Genre.create(genre: "Science Fiction") +slasher=Genre.create(genre: "Slasher") -m1 = Movie.create(title: "Groundhog Day", genre: "rom_com", showtime: 6, theater: "Commando Theater") -m2 = Movie.create(title: "Clueless", genre: "rom_com", showtime: 3, theater: "Commando Theater") -m3 = Movie.create(title: "Sleepless in Seattle", genre: "rom_com", showtime: 11, theater: "Commando Theater") -m4 = Movie.create(title: "Rush Hour", genre: "action", showtime: 4, theater: "Commando Theater") -m5 = Movie.create(title: "The Matrix", genre: "action", showtime: 12, theater: "Commando Theater") -m6 = Movie.create(title: "Inside Man", genre: "action", showtime: 6, theater: "Commando Theater") -m7 = Movie.create(title: "Mars Attacks", genre: "sci_fi", showtime: 9, theater: "Commando Theater") -m8 = Movie.create(title: "Predator", genre: "sci_fi", showtime: 12, theater: "Commando Theater") -m9 = Movie.create(title: "Jurassic Park", genre: "sci_fi", showtime: 4, theater: "Commando Theater") -m10 = Movie.create(title: "I Know What You Did Last Summer", genre: "slasher", showtime: 11, theater: "Commando Theater") -m11 = Movie.create(title: "Scream", genre: "slasher", showtime: 12, theater: "Commando Theater") -m12 = Movie.create(title: "Halloween", genre: "slasher", showtime: 10, theater: "Commando Theater") +g1=Guest.create(name: "Hadi") +g2=Guest.create(name: "Donovan") +g3=Guest.create(name: "Drake") +g4=Guest.create(name: "Sonny") +g5=Guest.create(name: "Shrek") +g6=Guest.create(name: "Neo") +g7=Guest.create(name: "Trinity") +g8=Guest.create(name: "P.Rudd") +g9=Guest.create(name: "Jackie Chan") +g10=Guest.create(name: "Bagheera") + +m1 = Movie.create(title: "Groundhog Day", genre_id: rom_com.id, showtime: 6, theater_id: commando.id ) +m2 = Movie.create(title: "Clueless", genre_id: rom_com.id, showtime: 3, theater_id: commando.id) +m3 = Movie.create(title: "Sleepless in Seattle", genre_id: rom_com.id, showtime: 11, theater_id: commando.id) +m4 = Movie.create(title: "Rush Hour", genre_id: action.id, showtime: 4, theater_id: commando.id) +m5 = Movie.create(title: "The Matrix", genre_id: action.id, showtime: 12, theater_id: commando.id) +m6 = Movie.create(title: "Inside Man", genre_id: action.id, showtime: 6, theater_id: commando.id ) +m7 = Movie.create(title: "Mars Attacks", genre_id: sci_fi.id, showtime: 9, theater_id:commando.id ) +m8 = Movie.create(title: "Predator", genre_id: sci_fi.id, showtime: 12, theater_id: commando.id ) +m9 = Movie.create(title: "Jurassic Park", genre_id: sci_fi.id, showtime: 4, theater_id: commando.id ) +m10 = Movie.create(title: "I Know What You Did Last Summer", genre_id: slasher.id, showtime: 11, theater_id: commando.id ) +m11 = Movie.create(title: "Scream", genre_id: slasher.id, showtime: 12, theater_id: commando.id ) +m12 = Movie.create(title: "Halloween", genre_id: slasher.id, showtime: 10, theater_id:commando.id ) -commando=Theater.create(name: "Commando Theater") -t1=Ticket.create(theater: "Commando Theater", movie: "Groundhog Day", guest: "Bagheera") -t2=Ticket.create(theater: "Commando Theater", movie: "Clueless", guest: "Bagheera") -t3=Ticket.create(theater: "Commando Theater", movie: "Sleepless in Seattle", guest: "Bagheera") -t4=Ticket.create(theater: "Commando Theater", movie: "Rush Hour", guest: "Bagheera") -t5=Ticket.create(theater: "Commando Theater", movie: "The Matrix", guest: "Bagheera") -t6=Ticket.create(theater: "Commando Theater", movie: "Inside Man", guest: "Bagheera") -t7=Ticket.create(theater: "Commando Theater", movie: "Mars Attacks", guest: "Bagheera") -t8=Ticket.create(theater: "Commando Theater", movie: "Predator", guest: "Bagheera") -t9=Ticket.create(theater: "Commando Theater", movie: "Jurassic Park", guest: "Bagheera") -t10=Ticket.create(theater: "Commando Theater", movie: "I Know What You Did Last Summer", guest: "Bagheera") -t11=Ticket.create(theater: "Commando Theater", movie: "Scream", guest: "Bagheera") -t12=Ticket.create(theater: "Commando Theater", movie: "Halloween", guest: "Bagheera") -t13=Ticket.create(theater: "Commando Theater", movie: "Clueless", guest: "Bagheera") -t14=Ticket.create(theater: "Commando Theater", movie: "Clueless", guest: "Bagheera") -t15=Ticket.create(theater: "Commando Theater", movie: "Rush Hour", guest: "Bagheera") -t16=Ticket.create(theater: "Commando Theater", movie: "Jurassic Park", guest: "Bagheera") -t17=Ticket.create(theater: "Commando Theater", movie: "Scream", guest: "Bagheera") +t1=Ticket.create(theater_id: commando.id, movie_id: m1.id, guest_id: g1.id) +t2=Ticket.create(theater_id: commando.id, movie_id: m2.id, guest_id: g2.id) +t3=Ticket.create(theater_id: commando.id, movie_id: m3.id, guest_id: g3.id) +t4=Ticket.create(theater_id: commando.id, movie_id: m4.id, guest_id: g4.id) +t5=Ticket.create(theater_id: commando.id, movie_id: m5.id, guest_id: g5.id) +t6=Ticket.create(theater_id: commando.id, movie_id: m6.id, guest_id: g6.id) +t7=Ticket.create(theater_id: commando.id, movie_id: m7.id, guest_id: g7.id) +t8=Ticket.create(theater_id: commando.id, movie_id: m8.id, guest_id: g8.id) +t9=Ticket.create(theater_id: commando.id, movie_id: m9.id, guest_id: g9.id) +t10=Ticket.create(theater_id: commando.id, movie_id: m10.id, guest_id: g10.id) +t11=Ticket.create(theater_id: commando.id, movie_id: m11.id, guest_id: g1.id) +t12=Ticket.create(theater_id: commando.id, movie_id: m12.id, guest_id: g1.id) +t13=Ticket.create(theater_id: commando.id, movie_id: m2.id, guest_id: g2.id) +t14=Ticket.create(theater_id: commando.id, movie_id: m2.id, guest_id: g2.id) +t15=Ticket.create(theater_id: commando.id, movie_id: m3.id, guest_id: g4.id) +t16=Ticket.create(theater_id: commando.id, movie_id: m9.id, guest_id: g5.id) +t17=Ticket.create(theater_id: commando.id, movie_id: m11.id, guest_id: g5.id) From 97a51474cb839d45201e071088a8c305058d7a7b Mon Sep 17 00:00:00 2001 From: hadi Date: Wed, 10 Mar 2021 11:10:45 -0600 Subject: [PATCH 09/25] stashing --- apps/models/genre.rb | 2 +- apps/models/guest.rb | 2 +- apps/models/movie.rb | 2 +- apps/models/theater.rb | 2 +- apps/models/ticket.rb | 2 +- db/migrate/20210309224256_create_movies_table.rb | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/models/genre.rb b/apps/models/genre.rb index 51c4327b..9251ae53 100644 --- a/apps/models/genre.rb +++ b/apps/models/genre.rb @@ -1,3 +1,3 @@ class Genre < ActiveRecord::Base - has_many :movie + has_many :movies end \ No newline at end of file diff --git a/apps/models/guest.rb b/apps/models/guest.rb index 2ba172d7..f81d1a22 100644 --- a/apps/models/guest.rb +++ b/apps/models/guest.rb @@ -1,3 +1,3 @@ class Guest < ActiveRecord::Base - has_many :ticket + has_many :tickets end \ No newline at end of file diff --git a/apps/models/movie.rb b/apps/models/movie.rb index f14a3d7f..d92f65de 100644 --- a/apps/models/movie.rb +++ b/apps/models/movie.rb @@ -1,5 +1,5 @@ class Movie < ActiveRecord::Base - belongs_to :theater + belongs_to :theaters #has_many :genre ????????????????????????????? end diff --git a/apps/models/theater.rb b/apps/models/theater.rb index 37bcf5b7..e2f1de41 100644 --- a/apps/models/theater.rb +++ b/apps/models/theater.rb @@ -1,3 +1,3 @@ class Theater < ActiveRecord::Base - has_many :guest :through :ticket + has_many :guests, through: :tickets end diff --git a/apps/models/ticket.rb b/apps/models/ticket.rb index cda88590..d0a552c8 100644 --- a/apps/models/ticket.rb +++ b/apps/models/ticket.rb @@ -1,3 +1,3 @@ class Ticket < ActiveRecord::Base - belongs_to :guest + belongs_to :guests end diff --git a/db/migrate/20210309224256_create_movies_table.rb b/db/migrate/20210309224256_create_movies_table.rb index 08d8164d..b9e6ab52 100644 --- a/db/migrate/20210309224256_create_movies_table.rb +++ b/db/migrate/20210309224256_create_movies_table.rb @@ -1,9 +1,9 @@ class CreateMoviesTable < ActiveRecord::Migration[6.1] def change create_table :movies do |t| - t.string :title - t.string :genre - t.integer :showtime + t.string :title_id + t.string :genre_id + t.integer :showtime_id t.string :theater end end From 6ad9646f2a4a82e8e0dddc6f0c3aefa5dd92542c Mon Sep 17 00:00:00 2001 From: github username Date: Wed, 10 Mar 2021 11:53:22 -0600 Subject: [PATCH 10/25] added associations and put useless commented out methods in models --- apps/models/genre.rb | 5 +++++ apps/models/guest.rb | 5 +++++ apps/models/movie.rb | 25 +++++++++++++++++++++++++ apps/models/theater.rb | 7 +++++++ apps/models/ticket.rb | 6 ++++++ bin/program.rb | 6 ++++++ 6 files changed, 54 insertions(+) diff --git a/apps/models/genre.rb b/apps/models/genre.rb index 9251ae53..07555b54 100644 --- a/apps/models/genre.rb +++ b/apps/models/genre.rb @@ -1,3 +1,8 @@ class Genre < ActiveRecord::Base has_many :movies + + # def self.genres + # #return all genres + # end + end \ No newline at end of file diff --git a/apps/models/guest.rb b/apps/models/guest.rb index cac6aa4c..a27411cf 100644 --- a/apps/models/guest.rb +++ b/apps/models/guest.rb @@ -1,3 +1,8 @@ class Guest < ActiveRecord::Base has_many :tickets + + # def self.guestbook + # #return all guests + # end + end \ No newline at end of file diff --git a/apps/models/movie.rb b/apps/models/movie.rb index 1395b210..0f530194 100644 --- a/apps/models/movie.rb +++ b/apps/models/movie.rb @@ -1,4 +1,29 @@ class Movie < ActiveRecord::Base belongs_to :theater + belongs_to :genre + + # def self.browse + # #return all movies + # end + + + + # def self.browse_by_genre(genre) + # #given argument of a genre returns list of all movies associated with genre) + + # ####Solution1#### + # #assign genre object a variable + # #call and return variables movies w/ variable.movies + + # ###Solution2### + # #find genres genre_id + # #iterate through movies + # #select ones that have said genre_id => return array + # #use that array find each movie title + # #return each movie title in array + + + # end + end diff --git a/apps/models/theater.rb b/apps/models/theater.rb index a31a89c8..c170bedb 100644 --- a/apps/models/theater.rb +++ b/apps/models/theater.rb @@ -1,3 +1,10 @@ class Theater < ActiveRecord::Base has_many :tickets + has_many :guests, through: :tickets + has_many :movies + + # def self.theaters + # #return theaters + # #MAYBE RETURN THEATERS AND THEIR MOVIES + # end end diff --git a/apps/models/ticket.rb b/apps/models/ticket.rb index 7da03b2e..d5447908 100644 --- a/apps/models/ticket.rb +++ b/apps/models/ticket.rb @@ -1,3 +1,9 @@ class Ticket < ActiveRecord::Base belongs_to :guest + belongs_to :theater + + # def self.purchases + # #return all purchases + # end + end diff --git a/bin/program.rb b/bin/program.rb index 204ce571..98109648 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -2,5 +2,11 @@ require_relative '../config/environment' +#####Deliverables for Program##### +#have a login prompt +#be able to save info + + + # binding.pry puts "HELLO WORLD" From 3ac71c4cd9e9ccf0d3852987ad7f8212eb2d9ecd Mon Sep 17 00:00:00 2001 From: github username Date: Wed, 10 Mar 2021 16:36:03 -0600 Subject: [PATCH 11/25] working_welcome_method_but_broken_search_method_at_purchase_step_and_ticket_association_with_movie --- Gemfile | 4 +++ Gemfile.lock | 22 +++++++++++++ apps/models/movie.rb | 11 +++++++ apps/models/ticket.rb | 1 + bin/program.rb | 76 ++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 113 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index c004f4ca..d85cfcbc 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,7 @@ gem "sinatra-activerecord" gem "sqlite3" gem "pry" gem "require_all" + +gem "artii", "~> 2.1" +gem "tty-prompt", "~> 0.21.0" +gem "colorize" diff --git a/Gemfile.lock b/Gemfile.lock index 511c4a10..67eccaa6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,14 +12,21 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) + artii (2.1.2) coderay (1.1.3) + colorize (0.8.1) concurrent-ruby (1.1.8) + equatable (0.6.1) i18n (1.8.9) concurrent-ruby (~> 1.0) method_source (1.0.0) minitest (5.14.4) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) + necromancer (0.5.1) + pastel (0.7.4) + equatable (~> 0.6) + tty-color (~> 0.5) pry (0.14.0) coderay (~> 1.1) method_source (~> 1.0) @@ -38,8 +45,20 @@ GEM sinatra (>= 1.0) sqlite3 (1.4.2) tilt (2.0.10) + tty-color (0.6.0) + tty-cursor (0.7.1) + tty-prompt (0.21.0) + necromancer (~> 0.5.0) + pastel (~> 0.7.0) + tty-reader (~> 0.7.0) + tty-reader (0.7.0) + tty-cursor (~> 0.7) + tty-screen (~> 0.7) + wisper (~> 2.0.0) + tty-screen (0.8.1) tzinfo (2.0.4) concurrent-ruby (~> 1.0) + wisper (2.0.1) zeitwerk (2.4.2) PLATFORMS @@ -47,10 +66,13 @@ PLATFORMS x86_64-linux DEPENDENCIES + artii (~> 2.1) + colorize pry require_all sinatra-activerecord sqlite3 + tty-prompt (~> 0.21.0) BUNDLED WITH 2.2.11 diff --git a/apps/models/movie.rb b/apps/models/movie.rb index 0f530194..b29a3d0b 100644 --- a/apps/models/movie.rb +++ b/apps/models/movie.rb @@ -2,6 +2,17 @@ class Movie < ActiveRecord::Base belongs_to :theater belongs_to :genre + # @@all = [] + + # def initialize + # @@all< "cursive") +puts "Welcome to" +puts title.asciify("Command Theater") +end + +def search + movies = Movie.all.map {|movie| movie.title} + prompt = TTY::Prompt.new + movie_choice = prompt.select("What would you like to see?", movies) + select_movie = Movie.find_by(title: movie_choice) + puts "You selected #{movie_choice}!!! We love that one" + menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"]) + if menu_options == "Purchase Ticket" + puts "Here is your ticket" + your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: Guest.all.first.id) + else + welcome + end + end + + + + # ticket_purchase = Ticket.create(theater_id: commando.id , movie_id: m11.id, guest_id: g5.id) + # ticket_purchase + + + + + + + + #####Deliverables for Program##### #have a login prompt #be able to save info +# def title +# fancy schmancy title +# end + +# def login +# kdajfdkljfadlkjfads +# end + +# def search +# where they say if they wanna view all movies or by genre +# end + +# def movie choice +# pick a showtime +# end + +# def purchase +# purchase movie choice at showtime choice +# end + +# def confirmation +# would you like to cancel +# end + +# def rating +# ask to leave rating +# end + +# def end goodbye +# thanks for purchasing . see you at showtime +# end + +# END + + + + + + # binding.pry -puts "HELLO WORLD" +# puts "HELLO WORLD" +welcome +search From 34f8799719571c60eaf13de25924c00b8773bfff Mon Sep 17 00:00:00 2001 From: hadi Date: Wed, 10 Mar 2021 16:37:53 -0600 Subject: [PATCH 12/25] adds login --- Gemfile | 5 ++++ Gemfile.lock | 23 ++++++++++++++- bin/program.rb | 37 +++++++++++++++++++++++++ db/migrate/20210310214457_hadichloun.rb | 5 ++++ db/schema.rb | 3 +- db/seeds.rb | 24 +++++++++------- 6 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 db/migrate/20210310214457_hadichloun.rb diff --git a/Gemfile b/Gemfile index c004f4ca..d5bb8a0c 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,8 @@ gem "sinatra-activerecord" gem "sqlite3" gem "pry" gem "require_all" + + +gem "artii", "~> 2.1" +gem "tty-prompt", "~> 0.21.0" +gem "colorize" \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 511c4a10..8265ccf3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,14 +12,21 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) + artii (2.1.2) coderay (1.1.3) + colorize (0.8.1) concurrent-ruby (1.1.8) + equatable (0.6.1) i18n (1.8.9) concurrent-ruby (~> 1.0) method_source (1.0.0) minitest (5.14.4) mustermann (1.1.1) ruby2_keywords (~> 0.0.1) + necromancer (0.5.1) + pastel (0.7.4) + equatable (~> 0.6) + tty-color (~> 0.5) pry (0.14.0) coderay (~> 1.1) method_source (~> 1.0) @@ -38,19 +45,33 @@ GEM sinatra (>= 1.0) sqlite3 (1.4.2) tilt (2.0.10) + tty-color (0.6.0) + tty-cursor (0.7.1) + tty-prompt (0.21.0) + necromancer (~> 0.5.0) + pastel (~> 0.7.0) + tty-reader (~> 0.7.0) + tty-reader (0.7.0) + tty-cursor (~> 0.7) + tty-screen (~> 0.7) + wisper (~> 2.0.0) + tty-screen (0.8.1) tzinfo (2.0.4) concurrent-ruby (~> 1.0) + wisper (2.0.1) zeitwerk (2.4.2) PLATFORMS - x86_64-darwin-20 x86_64-linux DEPENDENCIES + artii (~> 2.1) + colorize pry require_all sinatra-activerecord sqlite3 + tty-prompt (~> 0.21.0) BUNDLED WITH 2.2.11 diff --git a/bin/program.rb b/bin/program.rb index 98109648..1968945d 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -10,3 +10,40 @@ # binding.pry puts "HELLO WORLD" + + + +def login + guests = Guest.all.map {|guest| guest.name} + prompt = TTY::Prompt.new + login_choice = prompt.select("What would you like to do?", ["Login", "Sign Up", "continue as a guest"]) + if (login_choice == "Login") + current_username = prompt.ask("What is your username?") + current_password = prompt.ask("What is your password?") + if guests.include?(current_username) && Guest.all.find_by(password: current_password) + puts "Enjoy you movie!" + else + puts "Incorrect username or password" + exit! + end + end +end + +# def signup +# guests = Guest.all.map {|guest| guest.name} +# prompt = TTY::Prompt.new +# signup_choice = prompt.select("create username?", ["Login", "Sign Up", "continue as a guest"]) +# if (signup_choice == "Signup") +# current_username = prompt.ask("What is your username?") +# current_password = prompt.ask("What is your password?") +# if guests.include?(current_username) && Guest.all.find_by(password: current_password) +# puts "Enjoy you movie!" +# else +# puts "Incorrect username or password" +# exit! +# end +# end +# end + + +login diff --git a/db/migrate/20210310214457_hadichloun.rb b/db/migrate/20210310214457_hadichloun.rb new file mode 100644 index 00000000..58e07316 --- /dev/null +++ b/db/migrate/20210310214457_hadichloun.rb @@ -0,0 +1,5 @@ +class Hadichloun < ActiveRecord::Migration[6.1] + def change + add_column(:guests, :password, :integer) + end +end diff --git a/db/schema.rb b/db/schema.rb index c227f4e8..82ec8d28 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.define(version: 2021_03_10_163524) do +ActiveRecord::Schema.define(version: 2021_03_10_214457) do create_table "genres", force: :cascade do |t| t.string "genre" @@ -18,6 +18,7 @@ create_table "guests", force: :cascade do |t| t.string "name" + t.integer "password" end create_table "movies", force: :cascade do |t| diff --git a/db/seeds.rb b/db/seeds.rb index 592c2e07..b9708aa0 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,6 +4,8 @@ Movie.destroy_all Ticket.destroy_all + + commando=Theater.create(name: "Commando Theater") rom_com=Genre.create(genre: "Romantic Comedy") @@ -11,16 +13,17 @@ sci_fi=Genre.create(genre: "Science Fiction") slasher=Genre.create(genre: "Slasher") -g1=Guest.create(name: "Hadi") -g2=Guest.create(name: "Donovan") -g3=Guest.create(name: "Drake") -g4=Guest.create(name: "Sonny") -g5=Guest.create(name: "Shrek") -g6=Guest.create(name: "Neo") -g7=Guest.create(name: "Trinity") -g8=Guest.create(name: "P.Rudd") -g9=Guest.create(name: "Jackie Chan") -g10=Guest.create(name: "Bagheera") +donovan = Guest.create(name: "theater", password: "123") +g1=Guest.create(name: "Hadi", password: "123") +g2=Guest.create(name: "Donovan", password: "123") +g3=Guest.create(name: "Drake", password: "123") +g4=Guest.create(name: "Sonny", password: "123") +g5=Guest.create(name: "Shrek", password: "123") +g6=Guest.create(name: "Neo", password: "123") +g7=Guest.create(name: "Trinity", password: "123") +g8=Guest.create(name: "P.Rudd", password: "123") +g9=Guest.create(name: "Jackie Chan", password: "123") +g10=Guest.create(name: "Bagheera", password: "123") m1 = Movie.create(title: "Groundhog Day", genre_id: rom_com.id, showtime: 6, theater_id: commando.id ) m2 = Movie.create(title: "Clueless", genre_id: rom_com.id, showtime: 3, theater_id: commando.id) @@ -53,3 +56,4 @@ t15=Ticket.create(theater_id: commando.id, movie_id: m3.id, guest_id: g4.id) t16=Ticket.create(theater_id: commando.id, movie_id: m9.id, guest_id: g5.id) t17=Ticket.create(theater_id: commando.id, movie_id: m11.id, guest_id: g5.id) + From e34a7b18a4f3e6f26b9681fc5515fe9955f90673 Mon Sep 17 00:00:00 2001 From: hadi Date: Wed, 10 Mar 2021 16:43:27 -0600 Subject: [PATCH 13/25] adds login --- bin/program.rb | 91 +++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 56 deletions(-) diff --git a/bin/program.rb b/bin/program.rb index 7577e18a..15c299e5 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -22,60 +22,39 @@ def search end end +def login + guests = Guest.all.map {|guest| guest.name} + prompt = TTY::Prompt.new + login_choice = prompt.select("What would you like to do?", ["Login", "Sign Up", "continue as a guest"]) + if (login_choice == "Login") + current_username = prompt.ask("What is your username?") + current_password = prompt.ask("What is your password?") + if guests.include?(current_username) && Guest.all.find_by(password: current_password) + puts "Enjoy you movie!" + else + puts "Incorrect username or password" + exit! + end + end +end - - # ticket_purchase = Ticket.create(theater_id: commando.id , movie_id: m11.id, guest_id: g5.id) - # ticket_purchase - - - - - - - - - -#####Deliverables for Program##### -#have a login prompt -#be able to save info -# def title -# fancy schmancy title -# end - -# def login -# kdajfdkljfadlkjfads -# end - -# def search -# where they say if they wanna view all movies or by genre -# end - -# def movie choice -# pick a showtime -# end - -# def purchase -# purchase movie choice at showtime choice -# end - -# def confirmation -# would you like to cancel -# end - -# def rating -# ask to leave rating -# end - -# def end goodbye -# thanks for purchasing . see you at showtime -# end - -# END - - - - - - - - +# def signup +# guests = Guest.all.map {|guest| guest.name} +# prompt = TTY::Prompt.new +# signup_choice = prompt.select("create username?", ["Login", "Sign Up", "continue as a guest"]) +# if (signup_choice == "Signup") +# current_username = prompt.ask("What is your username?") +# current_password = prompt.ask("What is your password?") +# if guests.include?(current_username) && Guest.all.find_by(password: current_password) +# puts "Enjoy you movie!" +# else +# puts "Incorrect username or password" +# exit! +# end +# end +# end + + +login +welcome +search From f1c70846ef66616ed0b6a81e408c433b447710c9 Mon Sep 17 00:00:00 2001 From: github username Date: Wed, 10 Mar 2021 17:28:25 -0600 Subject: [PATCH 14/25] setting up more program --- Gemfile | 8 ++----- Gemfile.lock | 1 + bin/program.rb | 52 ++++++++++++++++++++++++++++++------------- config/environment.rb | 1 + 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/Gemfile b/Gemfile index 4aedeaea..2feae70a 100644 --- a/Gemfile +++ b/Gemfile @@ -6,13 +6,9 @@ gem "sqlite3" gem "pry" gem "require_all" -<<<<<<< HEAD + gem "artii", "~> 2.1" gem "tty-prompt", "~> 0.21.0" gem "colorize" -======= -gem "artii", "~> 2.1" -gem "tty-prompt", "~> 0.21.0" -gem "colorize" ->>>>>>> 3ac71c4cd9e9ccf0d3852987ad7f8212eb2d9ecd + diff --git a/Gemfile.lock b/Gemfile.lock index 8265ccf3..67eccaa6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,6 +62,7 @@ GEM zeitwerk (2.4.2) PLATFORMS + x86_64-darwin-20 x86_64-linux DEPENDENCIES diff --git a/bin/program.rb b/bin/program.rb index 15c299e5..0d32e038 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -7,21 +7,6 @@ def welcome puts title.asciify("Command Theater") end -def search - movies = Movie.all.map {|movie| movie.title} - prompt = TTY::Prompt.new - movie_choice = prompt.select("What would you like to see?", movies) - select_movie = Movie.find_by(title: movie_choice) - puts "You selected #{movie_choice}!!! We love that one" - menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"]) - if menu_options == "Purchase Ticket" - puts "Here is your ticket" - your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: Guest.all.first.id) - else - welcome - end - end - def login guests = Guest.all.map {|guest| guest.name} prompt = TTY::Prompt.new @@ -38,6 +23,40 @@ def login end end +def search + movies = Movie.all.map {|movie| movie.title} + prompt = TTY::Prompt.new + movie_choice = prompt.select("What would you like to see?", movies) + select_movie = Movie.find_by(title: movie_choice) + puts "You selected #{movie_choice}!!! We love that one!" + menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"]) + if menu_options == "Purchase Ticket" + puts "Here is your ticket! Excited yet?!" + your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: Guest.all.first.id) + puts your_ticket + puts "You're going to see #{your_ticket.movie.title} at #{your_ticket.theater.name}. " + else + welcome + end + end + + def thanks + puts "Thank you for your purchase! Commando Theater is b.y.o.b so feel free and WELCOME to bring your own refreshments. We cant wait to watch a movie with you!" + prompt = TTY::Prompt.new + thanks_choice = prompt.select("What would you like to do?", ["Rate Your Commando Expereince", "Start Over"]) + if thanks_choice == "Rate Your Commando Experience" + rate= prompt.select("Give us a rating...", ["1", "2", "3", "4", "5"]) + if rate == "1" + puts "Thank you for your feedback" + end + end + end + + + + + + # def signup # guests = Guest.all.map {|guest| guest.name} # prompt = TTY::Prompt.new @@ -55,6 +74,7 @@ def login # end -login welcome +login search +thanks diff --git a/config/environment.rb b/config/environment.rb index 340a0e40..feba57b2 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -3,4 +3,5 @@ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: 'db/development.db') +ActiveRecord::Base.logger = nil require_all 'apps' From 4e95a220f4e38959d21953a5e7e1ed9ba5520e45 Mon Sep 17 00:00:00 2001 From: hadi Date: Wed, 10 Mar 2021 17:30:29 -0600 Subject: [PATCH 15/25] merging --- Gemfile | 7 +------ bin/program.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 4aedeaea..80e2725c 100644 --- a/Gemfile +++ b/Gemfile @@ -6,13 +6,8 @@ gem "sqlite3" gem "pry" gem "require_all" -<<<<<<< HEAD + gem "artii", "~> 2.1" gem "tty-prompt", "~> 0.21.0" gem "colorize" -======= -gem "artii", "~> 2.1" -gem "tty-prompt", "~> 0.21.0" -gem "colorize" ->>>>>>> 3ac71c4cd9e9ccf0d3852987ad7f8212eb2d9ecd diff --git a/bin/program.rb b/bin/program.rb index 15c299e5..bfc5eee8 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -58,3 +58,11 @@ def login login welcome search + + + + + +# 10.times do +# Ticket.create(address: Guest::Com_1.theater) +# end \ No newline at end of file From ad8268128f62100f1a6cf924b2e24281e4cfdb36 Mon Sep 17 00:00:00 2001 From: hadi Date: Wed, 10 Mar 2021 17:32:57 -0600 Subject: [PATCH 16/25] merges1 --- Gemfile | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Gemfile b/Gemfile index 4aedeaea..c48b9d73 100644 --- a/Gemfile +++ b/Gemfile @@ -6,13 +6,7 @@ gem "sqlite3" gem "pry" gem "require_all" -<<<<<<< HEAD gem "artii", "~> 2.1" gem "tty-prompt", "~> 0.21.0" gem "colorize" -======= -gem "artii", "~> 2.1" -gem "tty-prompt", "~> 0.21.0" -gem "colorize" ->>>>>>> 3ac71c4cd9e9ccf0d3852987ad7f8212eb2d9ecd From 9e5bc75050a707cf1beb5f0e11cd821c8a773c69 Mon Sep 17 00:00:00 2001 From: github username Date: Wed, 10 Mar 2021 17:39:35 -0600 Subject: [PATCH 17/25] meh --- bin/program.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/program.rb b/bin/program.rb index 0d32e038..d04375c7 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -47,7 +47,7 @@ def thanks if thanks_choice == "Rate Your Commando Experience" rate= prompt.select("Give us a rating...", ["1", "2", "3", "4", "5"]) if rate == "1" - puts "Thank you for your feedback" + puts "Thank you for your feedback." end end end From 92a100a624ade6e400986653541531d91501bc3c Mon Sep 17 00:00:00 2001 From: hadi Date: Thu, 11 Mar 2021 10:11:36 -0600 Subject: [PATCH 18/25] maerging --- Gemfile.lock | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ bin/program.rb | 65 ++++++++++++++++++++++-------------------- 2 files changed, 112 insertions(+), 30 deletions(-) create mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..8265ccf3 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,77 @@ +GEM + remote: https://rubygems.org/ + specs: + activemodel (6.1.3) + activesupport (= 6.1.3) + activerecord (6.1.3) + activemodel (= 6.1.3) + activesupport (= 6.1.3) + activesupport (6.1.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + artii (2.1.2) + coderay (1.1.3) + colorize (0.8.1) + concurrent-ruby (1.1.8) + equatable (0.6.1) + i18n (1.8.9) + concurrent-ruby (~> 1.0) + method_source (1.0.0) + minitest (5.14.4) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + necromancer (0.5.1) + pastel (0.7.4) + equatable (~> 0.6) + tty-color (~> 0.5) + pry (0.14.0) + coderay (~> 1.1) + method_source (~> 1.0) + rack (2.2.3) + rack-protection (2.1.0) + rack + require_all (3.0.0) + ruby2_keywords (0.0.4) + sinatra (2.1.0) + mustermann (~> 1.0) + rack (~> 2.2) + rack-protection (= 2.1.0) + tilt (~> 2.0) + sinatra-activerecord (2.0.22) + activerecord (>= 4.1) + sinatra (>= 1.0) + sqlite3 (1.4.2) + tilt (2.0.10) + tty-color (0.6.0) + tty-cursor (0.7.1) + tty-prompt (0.21.0) + necromancer (~> 0.5.0) + pastel (~> 0.7.0) + tty-reader (~> 0.7.0) + tty-reader (0.7.0) + tty-cursor (~> 0.7) + tty-screen (~> 0.7) + wisper (~> 2.0.0) + tty-screen (0.8.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + wisper (2.0.1) + zeitwerk (2.4.2) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + artii (~> 2.1) + colorize + pry + require_all + sinatra-activerecord + sqlite3 + tty-prompt (~> 0.21.0) + +BUNDLED WITH + 2.2.11 diff --git a/bin/program.rb b/bin/program.rb index 80f6de4f..fcd27238 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -7,21 +7,44 @@ def welcome puts title.asciify("Command Theater") end +def signup + # guests = Guest.all.map {|guest| guest.name} + prompt = TTY::Prompt.new + # signup_choice = prompt.collect do + g = prompt.ask('Create your username.') + $guest= Guest.create(name: g, password: 123) + # if Guest.all.map {|guest| guest.name}.include?(g) + # puts "username you provided has been used already!" + + end + + def login - guests = Guest.all.map {|guest| guest.name} + # guests = Guest.all.map {|guest| guest.name} prompt = TTY::Prompt.new - login_choice = prompt.select("What would you like to do?", ["Login", "Sign Up", "continue as a guest"]) - if (login_choice == "Login") - current_username = prompt.ask("What is your username?") - current_password = prompt.ask("What is your password?") - if guests.include?(current_username) && Guest.all.find_by(password: current_password) - puts "Enjoy you movie!" - else - puts "Incorrect username or password" - exit! + login_choice = prompt.select("What would you like to do?", ["Signup"]) + # if (login_choice == "Login") + # current_username = prompt.ask("What is your username?") + # current_password = prompt.ask("What is your password?") + # if guests.include?(current_username) && Guest.all.find_by(password: current_password) + # puts "Enjoy you movie!" + if (login_choice == "Signup") + prompt = TTY::Prompt.new + # signup_choice = prompt.collect do + new_username = prompt.ask('Create your username.') + new_password = prompt.ask("What is your password?") + $guest= Guest.create(name: new_username, password: new_password) + # if Guest.all.map {|guest| guest.name}.include?(g) + # puts "username you provided has been used already!" + + # else + # puts "Incorrect username or password" + # exit! end end -end + + + def search movies = Movie.all.map {|movie| movie.title} @@ -32,7 +55,7 @@ def search menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"]) if menu_options == "Purchase Ticket" puts "Here is your ticket! Excited yet?!" - your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: Guest.all.first.id) + your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: $guest.id) puts your_ticket puts "You're going to see #{your_ticket.movie.title} at #{your_ticket.theater.name}. " else @@ -56,24 +79,6 @@ def thanks - -# def signup -# guests = Guest.all.map {|guest| guest.name} -# prompt = TTY::Prompt.new -# signup_choice = prompt.select("create username?", ["Login", "Sign Up", "continue as a guest"]) -# if (signup_choice == "Signup") -# current_username = prompt.ask("What is your username?") -# current_password = prompt.ask("What is your password?") -# if guests.include?(current_username) && Guest.all.find_by(password: current_password) -# puts "Enjoy you movie!" -# else -# puts "Incorrect username or password" -# exit! -# end -# end -# end - - welcome login search From 701d241504e5110ad1b9d764a2726d77b6d7b86f Mon Sep 17 00:00:00 2001 From: github username Date: Thu, 11 Mar 2021 10:18:15 -0600 Subject: [PATCH 19/25] this shit still confuses me --- Gemfile.lock | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ bin/program.rb | 8 ++++++ 2 files changed, 85 insertions(+) create mode 100644 Gemfile.lock diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..92f95da3 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,77 @@ +GEM + remote: https://rubygems.org/ + specs: + activemodel (6.1.3) + activesupport (= 6.1.3) + activerecord (6.1.3) + activemodel (= 6.1.3) + activesupport (= 6.1.3) + activesupport (6.1.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + artii (2.1.2) + coderay (1.1.3) + colorize (0.8.1) + concurrent-ruby (1.1.8) + equatable (0.6.1) + i18n (1.8.9) + concurrent-ruby (~> 1.0) + method_source (1.0.0) + minitest (5.14.4) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + necromancer (0.5.1) + pastel (0.7.4) + equatable (~> 0.6) + tty-color (~> 0.5) + pry (0.14.0) + coderay (~> 1.1) + method_source (~> 1.0) + rack (2.2.3) + rack-protection (2.1.0) + rack + require_all (3.0.0) + ruby2_keywords (0.0.4) + sinatra (2.1.0) + mustermann (~> 1.0) + rack (~> 2.2) + rack-protection (= 2.1.0) + tilt (~> 2.0) + sinatra-activerecord (2.0.22) + activerecord (>= 4.1) + sinatra (>= 1.0) + sqlite3 (1.4.2) + tilt (2.0.10) + tty-color (0.6.0) + tty-cursor (0.7.1) + tty-prompt (0.21.0) + necromancer (~> 0.5.0) + pastel (~> 0.7.0) + tty-reader (~> 0.7.0) + tty-reader (0.7.0) + tty-cursor (~> 0.7) + tty-screen (~> 0.7) + wisper (~> 2.0.0) + tty-screen (0.8.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + wisper (2.0.1) + zeitwerk (2.4.2) + +PLATFORMS + x86_64-darwin-20 + +DEPENDENCIES + artii (~> 2.1) + colorize + pry + require_all + sinatra-activerecord + sqlite3 + tty-prompt (~> 0.21.0) + +BUNDLED WITH + 2.2.13 diff --git a/bin/program.rb b/bin/program.rb index bc3b2880..7124cffd 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -1,6 +1,7 @@ require 'pry' require_relative '../config/environment' + def welcome title=Artii::Base.new(:font=> "cursive") puts "Welcome to" @@ -37,6 +38,9 @@ def search puts "You're going to see #{your_ticket.movie.title} at #{your_ticket.theater.name}. " else welcome + login + search + thanks end end @@ -46,11 +50,15 @@ def thanks thanks_choice = prompt.select("What would you like to do?", ["Rate Your Commando Expereince", "Start Over"]) if thanks_choice == "Rate Your Commando Experience" rate= prompt.select("Give us a rating...", ["1", "2", "3", "4", "5"]) + ###for thursday figure out why options not showing up if rate == "1" puts "Thank you for your feedback." end end end + + + From c98a82eb71033996bc90db1f366de9922371ff5c Mon Sep 17 00:00:00 2001 From: github username Date: Thu, 11 Mar 2021 14:48:56 -0600 Subject: [PATCH 20/25] search by genre --- bin/program.rb | 107 ++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 55 deletions(-) diff --git a/bin/program.rb b/bin/program.rb index 7124cffd..12749fab 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -1,89 +1,86 @@ require 'pry' require_relative '../config/environment' - def welcome title=Artii::Base.new(:font=> "cursive") puts "Welcome to" puts title.asciify("Command Theater") end + def login - guests = Guest.all.map {|guest| guest.name} prompt = TTY::Prompt.new - login_choice = prompt.select("What would you like to do?", ["Login", "Sign Up", "continue as a guest"]) - if (login_choice == "Login") - current_username = prompt.ask("What is your username?") - current_password = prompt.ask("What is your password?") - if guests.include?(current_username) && Guest.all.find_by(password: current_password) - puts "Enjoy you movie!" - else - puts "Incorrect username or password" - exit! + login_choice = prompt.select("What would you like to do?", ["Signup"]) + if (login_choice == "Signup") + prompt = TTY::Prompt.new + new_username = prompt.ask('Create your username') + new_password = prompt.ask("What is your password?") + $guest= Guest.create(name: new_username, password: new_password) end end -end + def search movies = Movie.all.map {|movie| movie.title} + genres = Genre.all.map {|genre| genre.genre} prompt = TTY::Prompt.new - movie_choice = prompt.select("What would you like to see?", movies) - select_movie = Movie.find_by(title: movie_choice) - puts "You selected #{movie_choice}!!! We love that one!" - menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"]) + search_choice = prompt.select("What would you like to see?", ["All Movies", "Genres"]) + if (search_choice == "All Movies") + prompt = TTY::Prompt.new + choice = prompt.select("Pick a movie", movies) + puts "You selected #{choice}!!! We love that one!" + select_movie = Movie.find_by(title: choice) + + menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"]) if menu_options == "Purchase Ticket" puts "Here is your ticket! Excited yet?!" - your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: Guest.all.first.id) + your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: $guest.id) puts your_ticket - puts "You're going to see #{your_ticket.movie.title} at #{your_ticket.theater.name}. " - else - welcome - login - search - thanks + puts "Please save this id for your confirmation number." + puts "You're going to see the #{select_movie.genre.genre} movie, #{your_ticket.movie.title}, @ #{select_movie.showtime} " end - end - - def thanks - puts "Thank you for your purchase! Commando Theater is b.y.o.b so feel free and WELCOME to bring your own refreshments. We cant wait to watch a movie with you!" - prompt = TTY::Prompt.new - thanks_choice = prompt.select("What would you like to do?", ["Rate Your Commando Expereince", "Start Over"]) - if thanks_choice == "Rate Your Commando Experience" - rate= prompt.select("Give us a rating...", ["1", "2", "3", "4", "5"]) - ###for thursday figure out why options not showing up - if rate == "1" - puts "Thank you for your feedback." - end - end + + elsif (search_choice == "Genres") + prompt = TTY::Prompt.new + genre_choice = prompt.select("Pick a genre", genres) + puts "You selected #{genre_choice}. That's a popular one!" + select_genre = Genre.find_by(genre: genre_choice) + genre_titles = select_genre.movies.map {|movie| movie.title} + prompt = TTY::Prompt.new + genre_movie_choice = prompt.select("Which movie?", genre_titles) + ticket_choice = Movie.find_by(title: genre_movie_choice) + + + prompt = TTY::Prompt.new + menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"]) + if menu_options == "Purchase Ticket" + puts "Here is your ticket! Excited yet?!" + your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: ticket_choice.id, guest_id: $guest.id) + puts your_ticket + puts "Please save this id for your confirmation number." + puts "You're going to see a #{ticket_choice.genre.genre} movie, #{your_ticket.movie.title}, @ #{ticket_choice.showtime} " + + else + welcome end + end +end - - - +####how to save rat + def thanks + puts "Thank you for your purchase! Commando Theater is b.y.o.b so feel free and WELCOME to bring your own refreshments. We cant wait to watch a movie with you!" + prompt = TTY::Prompt.new + thanks_choice = prompt.ask("Please leave us a rating from 1-5") + puts "Thank you for your feedback!" + end -# def signup -# guests = Guest.all.map {|guest| guest.name} -# prompt = TTY::Prompt.new -# signup_choice = prompt.select("create username?", ["Login", "Sign Up", "continue as a guest"]) -# if (signup_choice == "Signup") -# current_username = prompt.ask("What is your username?") -# current_password = prompt.ask("What is your password?") -# if guests.include?(current_username) && Guest.all.find_by(password: current_password) -# puts "Enjoy you movie!" -# else -# puts "Incorrect username or password" -# exit! -# end -# end -# end welcome login search thanks - From 6ac334c272885597b4c5c979b44dcb7652e966ac Mon Sep 17 00:00:00 2001 From: hadi Date: Thu, 11 Mar 2021 15:00:48 -0600 Subject: [PATCH 21/25] fixes sign up --- Gemfile.lock | 8 -------- bin/program.rb | 11 ++++------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 633727d7..8265ccf3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,11 +62,7 @@ GEM zeitwerk (2.4.2) PLATFORMS -<<<<<<< HEAD x86_64-linux -======= - x86_64-darwin-20 ->>>>>>> c98a82eb71033996bc90db1f366de9922371ff5c DEPENDENCIES artii (~> 2.1) @@ -78,8 +74,4 @@ DEPENDENCIES tty-prompt (~> 0.21.0) BUNDLED WITH -<<<<<<< HEAD 2.2.11 -======= - 2.2.13 ->>>>>>> c98a82eb71033996bc90db1f366de9922371ff5c diff --git a/bin/program.rb b/bin/program.rb index 76a529f5..6c728dc0 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -14,7 +14,7 @@ def signup if (login_choice == "Sign Up") new_username = prompt.ask("What is your username?") new_password = prompt.ask("What is your password?") - Guest.create(name: "#{new_username}", password: "#{new_password}") + $g = Guest.create(name: "#{new_username}", password: "#{new_password}") puts "Lets start watching!" else @@ -22,9 +22,6 @@ def signup exit! end end -welcome -signup - @@ -43,7 +40,7 @@ def search menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"]) if menu_options == "Purchase Ticket" puts "Here is your ticket! Excited yet?!" - your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: $guest.id) + your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: $g.id) puts your_ticket puts "Please save this id for your confirmation number." puts "You're going to see the #{select_movie.genre.genre} movie, #{your_ticket.movie.title}, @ #{select_movie.showtime} " @@ -64,7 +61,7 @@ def search menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"]) if menu_options == "Purchase Ticket" puts "Here is your ticket! Excited yet?!" - your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: ticket_choice.id, guest_id: $guest.id) + your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: ticket_choice.id, guest_id: $g.id) puts your_ticket puts "Please save this id for your confirmation number." puts "You're going to see a #{ticket_choice.genre.genre} movie, #{your_ticket.movie.title}, @ #{ticket_choice.showtime} " @@ -90,6 +87,6 @@ def thanks welcome -login +signup search thanks From 01eac84a6d0ec1805e473c1d9aac298d4905a59a Mon Sep 17 00:00:00 2001 From: github username Date: Thu, 11 Mar 2021 16:14:04 -0600 Subject: [PATCH 22/25] login --- Gemfile.lock | 1 + bin/program.rb | 39 ++++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8265ccf3..67eccaa6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,6 +62,7 @@ GEM zeitwerk (2.4.2) PLATFORMS + x86_64-darwin-20 x86_64-linux DEPENDENCIES diff --git a/bin/program.rb b/bin/program.rb index 6c728dc0..59d1b927 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -8,24 +8,34 @@ def welcome end -def signup +def signup + prompt = TTY::Prompt.new - login_choice = prompt.select("New users please Sign Up",["Sign Up", "Exit"]) + login_choice = prompt.select("New users please Sign Up",["Sign Up", "Login", "Exit"]) #could say "Log in or new user please sign up and put login back in as an option IF + if (login_choice == "Sign Up") - new_username = prompt.ask("What is your username?") - new_password = prompt.ask("What is your password?") - $g = Guest.create(name: "#{new_username}", password: "#{new_password}") + $new_username = prompt.ask("What is your username?") + $new_password = prompt.ask("What is your password? Must only include numbers") + $g = Guest.create(name: "#{$new_username}", password: "#{$new_password}") puts "Lets start watching!" + elsif login_choice == "Login" + name = prompt.ask("What username?") + password = prompt.ask("What pass?") + users = Guest.all.map{|u| u.name} + if users.include?(name) && Guest.find_by(password: password) + #assign variable of guest + $g = Guest.find_by(name: name) + puts "Hello #{$g.name} lets buy a ticket" + end + else - puts "Incorrect username or password" exit! end end - def search movies = Movie.all.map {|movie| movie.title} genres = Genre.all.map {|genre| genre.genre} @@ -37,13 +47,13 @@ def search puts "You selected #{choice}!!! We love that one!" select_movie = Movie.find_by(title: choice) - menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"]) + menu_options = prompt.select("What would you like to do next", ["Purchase Ticket"]) if menu_options == "Purchase Ticket" puts "Here is your ticket! Excited yet?!" your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: $g.id) puts your_ticket puts "Please save this id for your confirmation number." - puts "You're going to see the #{select_movie.genre.genre} movie, #{your_ticket.movie.title}, @ #{select_movie.showtime} " + puts "You're going to see the #{select_movie.genre.genre}, #{your_ticket.movie.title}, @ #{select_movie.showtime} " end elsif (search_choice == "Genres") @@ -58,16 +68,13 @@ def search prompt = TTY::Prompt.new - menu_options = prompt.select("What would you like to do next", ["Purchase Ticket", "Start Over"]) - if menu_options == "Purchase Ticket" + menu_options = prompt.select("What would you like to do next", ["Purchase Ticket"]) + if (menu_options == "Purchase Ticket") puts "Here is your ticket! Excited yet?!" your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: ticket_choice.id, guest_id: $g.id) puts your_ticket puts "Please save this id for your confirmation number." - puts "You're going to see a #{ticket_choice.genre.genre} movie, #{your_ticket.movie.title}, @ #{ticket_choice.showtime} " - - else - welcome + puts "You're going to see a #{ticket_choice.genre.genre}, #{your_ticket.movie.title}, @ #{ticket_choice.showtime} " end end end @@ -82,7 +89,9 @@ def thanks prompt = TTY::Prompt.new thanks_choice = prompt.ask("Please leave us a rating from 1-5") puts "Thank you for your feedback!" + # puts "Here are your Commando login credentials. Username: #{$new_username} Password: #{$new_password}. We hope to see you again soon!" end + From b03fe4f19777f1b8ab08f27c017106a4becbb3a1 Mon Sep 17 00:00:00 2001 From: github username Date: Thu, 11 Mar 2021 16:50:33 -0600 Subject: [PATCH 23/25] delete ticket --- bin/program.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bin/program.rb b/bin/program.rb index 59d1b927..e21e3d50 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -26,9 +26,21 @@ def signup if users.include?(name) && Guest.find_by(password: password) #assign variable of guest $g = Guest.find_by(name: name) - puts "Hello #{$g.name} lets buy a ticket" + puts "Hello #{$g.name}." + guest_choice = prompt.select("What would you like to do?", ["Review Orders", "Continue Browsing"]) + if guest_choice == "Review Orders" + puts $g.tickets + # puts "You were scheduled to see #{$g.tickets.movie}" + option = prompt.select("What next?", ["Cancel Ticket", "Continue Browsing"]) + if option == "Cancel Ticket" + $g.tickets.delete + puts "#{$g.name}, your ticket has been deleted." + exit! + end + elsif guest_choice == "Continue Browsing" + search + end end - else exit! end @@ -36,6 +48,8 @@ def signup + + def search movies = Movie.all.map {|movie| movie.title} genres = Genre.all.map {|genre| genre.genre} From 3b9fbfdb3c9aa17f3b3719a68b981db14efc1331 Mon Sep 17 00:00:00 2001 From: github username Date: Thu, 11 Mar 2021 17:47:10 -0600 Subject: [PATCH 24/25] added colors changed font --- bin/program.rb | 12 ++++++------ db/seeds.rb | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/bin/program.rb b/bin/program.rb index e21e3d50..3b70c100 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -2,16 +2,16 @@ require_relative '../config/environment' def welcome -title=Artii::Base.new(:font=> "cursive") +title=Artii::Base.new(:font=> "cosmic") puts "Welcome to" -puts title.asciify("Command Theater") +puts title.asciify("Command Theater").colorize(:blue) end def signup prompt = TTY::Prompt.new - login_choice = prompt.select("New users please Sign Up",["Sign Up", "Login", "Exit"]) #could say "Log in or new user please sign up and put login back in as an option IF + login_choice = prompt.select("New users please Sign Up",["Sign Up", "Login", ("Exit").colorize(:red)]) #could say "Log in or new user please sign up and put login back in as an option IF if (login_choice == "Sign Up") $new_username = prompt.ask("What is your username?") @@ -66,7 +66,7 @@ def search puts "Here is your ticket! Excited yet?!" your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: select_movie.id, guest_id: $g.id) puts your_ticket - puts "Please save this id for your confirmation number." + puts ("Please save this id for your confirmation number.").colorize(:magenta) puts "You're going to see the #{select_movie.genre.genre}, #{your_ticket.movie.title}, @ #{select_movie.showtime} " end @@ -87,7 +87,7 @@ def search puts "Here is your ticket! Excited yet?!" your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: ticket_choice.id, guest_id: $g.id) puts your_ticket - puts "Please save this id for your confirmation number." + puts ("Please save this id for your confirmation number.").colorize(:magenta) puts "You're going to see a #{ticket_choice.genre.genre}, #{your_ticket.movie.title}, @ #{ticket_choice.showtime} " end end @@ -102,7 +102,7 @@ def thanks puts "Thank you for your purchase! Commando Theater is b.y.o.b so feel free and WELCOME to bring your own refreshments. We cant wait to watch a movie with you!" prompt = TTY::Prompt.new thanks_choice = prompt.ask("Please leave us a rating from 1-5") - puts "Thank you for your feedback!" + puts ("Thank you for your feedback!").colorize(:yellow) # puts "Here are your Commando login credentials. Username: #{$new_username} Password: #{$new_password}. We hope to see you again soon!" end diff --git a/db/seeds.rb b/db/seeds.rb index b9708aa0..ed6d59ee 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -8,10 +8,10 @@ commando=Theater.create(name: "Commando Theater") -rom_com=Genre.create(genre: "Romantic Comedy") -action=Genre.create(genre: "Action") -sci_fi=Genre.create(genre: "Science Fiction") -slasher=Genre.create(genre: "Slasher") +rom_com=Genre.create(genre: ("Romantic Comedy").colorize(:cyan)) +action=Genre.create(genre: ("Action").colorize(:cyan)) +sci_fi=Genre.create(genre: ("Science Fiction").colorize(:cyan)) +slasher=Genre.create(genre: ("Slasher").colorize(:cyan)) donovan = Guest.create(name: "theater", password: "123") g1=Guest.create(name: "Hadi", password: "123") @@ -25,18 +25,18 @@ g9=Guest.create(name: "Jackie Chan", password: "123") g10=Guest.create(name: "Bagheera", password: "123") -m1 = Movie.create(title: "Groundhog Day", genre_id: rom_com.id, showtime: 6, theater_id: commando.id ) -m2 = Movie.create(title: "Clueless", genre_id: rom_com.id, showtime: 3, theater_id: commando.id) -m3 = Movie.create(title: "Sleepless in Seattle", genre_id: rom_com.id, showtime: 11, theater_id: commando.id) -m4 = Movie.create(title: "Rush Hour", genre_id: action.id, showtime: 4, theater_id: commando.id) -m5 = Movie.create(title: "The Matrix", genre_id: action.id, showtime: 12, theater_id: commando.id) -m6 = Movie.create(title: "Inside Man", genre_id: action.id, showtime: 6, theater_id: commando.id ) -m7 = Movie.create(title: "Mars Attacks", genre_id: sci_fi.id, showtime: 9, theater_id:commando.id ) -m8 = Movie.create(title: "Predator", genre_id: sci_fi.id, showtime: 12, theater_id: commando.id ) -m9 = Movie.create(title: "Jurassic Park", genre_id: sci_fi.id, showtime: 4, theater_id: commando.id ) -m10 = Movie.create(title: "I Know What You Did Last Summer", genre_id: slasher.id, showtime: 11, theater_id: commando.id ) -m11 = Movie.create(title: "Scream", genre_id: slasher.id, showtime: 12, theater_id: commando.id ) -m12 = Movie.create(title: "Halloween", genre_id: slasher.id, showtime: 10, theater_id:commando.id ) +m1 = Movie.create(title: ("Groundhog Day").colorize(:light_blue), genre_id: rom_com.id, showtime: 6, theater_id: commando.id ) +m2 = Movie.create(title: ("Clueless").colorize(:light_blue), genre_id: rom_com.id, showtime: 3, theater_id: commando.id) +m3 = Movie.create(title: ("Sleepless in Seattle").colorize(:light_blue), genre_id: rom_com.id, showtime: 11, theater_id: commando.id) +m4 = Movie.create(title: ("Rush Hour").colorize(:light_blue), genre_id: action.id, showtime: 4, theater_id: commando.id) +m5 = Movie.create(title: ("The Matrix").colorize(:light_blue), genre_id: action.id, showtime: 12, theater_id: commando.id) +m6 = Movie.create(title: ("Inside Man").colorize(:light_blue), genre_id: action.id, showtime: 6, theater_id: commando.id ) +m7 = Movie.create(title: ("Mars Attacks").colorize(:light_blue), genre_id: sci_fi.id, showtime: 9, theater_id:commando.id ) +m8 = Movie.create(title: ("Predator").colorize(:light_blue), genre_id: sci_fi.id, showtime: 12, theater_id: commando.id ) +m9 = Movie.create(title: ("Jurassic Park").colorize(:light_blue), genre_id: sci_fi.id, showtime: 4, theater_id: commando.id ) +m10 = Movie.create(title: ("I Know What You Did Last Summer").colorize(:light_blue), genre_id: slasher.id, showtime: 11, theater_id: commando.id ) +m11 = Movie.create(title: ("Scream").colorize(:light_blue), genre_id: slasher.id, showtime: 12, theater_id: commando.id ) +m12 = Movie.create(title: ("Halloween").colorize(:light_blue), genre_id: slasher.id, showtime: 10, theater_id:commando.id ) t1=Ticket.create(theater_id: commando.id, movie_id: m1.id, guest_id: g1.id) From 1e22a553bcfa65b56961d0fc4bb9a8a6fcf404dc Mon Sep 17 00:00:00 2001 From: github username Date: Fri, 12 Mar 2021 09:43:30 -0600 Subject: [PATCH 25/25] final touches and readme2 --- README2.md | 28 ++++++++++++++++++++++++++++ apps/models/genre.rb | 5 ----- apps/models/guest.rb | 5 ----- apps/models/movie.rb | 37 ------------------------------------- apps/models/theater.rb | 6 +----- apps/models/ticket.rb | 5 ----- bin/program.rb | 21 ++++----------------- db/seeds.rb | 3 --- 8 files changed, 33 insertions(+), 77 deletions(-) create mode 100644 README2.md diff --git a/README2.md b/README2.md new file mode 100644 index 00000000..3e152c6f --- /dev/null +++ b/README2.md @@ -0,0 +1,28 @@ +## Module One Project +## Commando Theater + +###### Objectives + + 1. Practice many-to-many and one-to-many relationships. + 2. Utilize ActiveRecord and maintain a database + 3. Interact with data using a CLI application + +### Introduction + +In this application the guest will be able to sign up, browse movies, purchase a ticket, +review their purchases, and cancel a ticket if they so choose. +The application will be run using the program.rb file. To be clear, in the +terminal run ruby bin/program.rb to start the application. Guest will then be able to run through the +entire process and re-run in order to sign in and view purchases. + +## Instructions + 1. Open new terminal + 2. Run ruby bin/program.rb + 3. Enjoy your Commando experience. + + + +# Notes +Be sure to have gems installed. +Prior to running the program file, user should "bundle install". + diff --git a/apps/models/genre.rb b/apps/models/genre.rb index 07555b54..9251ae53 100644 --- a/apps/models/genre.rb +++ b/apps/models/genre.rb @@ -1,8 +1,3 @@ class Genre < ActiveRecord::Base has_many :movies - - # def self.genres - # #return all genres - # end - end \ No newline at end of file diff --git a/apps/models/guest.rb b/apps/models/guest.rb index a27411cf..cac6aa4c 100644 --- a/apps/models/guest.rb +++ b/apps/models/guest.rb @@ -1,8 +1,3 @@ class Guest < ActiveRecord::Base has_many :tickets - - # def self.guestbook - # #return all guests - # end - end \ No newline at end of file diff --git a/apps/models/movie.rb b/apps/models/movie.rb index fb4a24df..764a4ebf 100644 --- a/apps/models/movie.rb +++ b/apps/models/movie.rb @@ -1,41 +1,4 @@ class Movie < ActiveRecord::Base belongs_to :theater belongs_to :genre - - # @@all = [] - - # def initialize - # @@all< return array - # #use that array find each movie title - # #return each movie title in array - - - # end - - - end diff --git a/apps/models/theater.rb b/apps/models/theater.rb index c170bedb..e067afba 100644 --- a/apps/models/theater.rb +++ b/apps/models/theater.rb @@ -2,9 +2,5 @@ class Theater < ActiveRecord::Base has_many :tickets has_many :guests, through: :tickets has_many :movies - - # def self.theaters - # #return theaters - # #MAYBE RETURN THEATERS AND THEIR MOVIES - # end end + diff --git a/apps/models/ticket.rb b/apps/models/ticket.rb index d4b839c7..a312b85c 100644 --- a/apps/models/ticket.rb +++ b/apps/models/ticket.rb @@ -2,9 +2,4 @@ class Ticket < ActiveRecord::Base belongs_to :guest belongs_to :theater belongs_to :movie - - # def self.purchases - # #return all purchases - # end - end diff --git a/bin/program.rb b/bin/program.rb index 3b70c100..256a5b76 100644 --- a/bin/program.rb +++ b/bin/program.rb @@ -24,13 +24,11 @@ def signup password = prompt.ask("What pass?") users = Guest.all.map{|u| u.name} if users.include?(name) && Guest.find_by(password: password) - #assign variable of guest $g = Guest.find_by(name: name) puts "Hello #{$g.name}." guest_choice = prompt.select("What would you like to do?", ["Review Orders", "Continue Browsing"]) if guest_choice == "Review Orders" puts $g.tickets - # puts "You were scheduled to see #{$g.tickets.movie}" option = prompt.select("What next?", ["Cancel Ticket", "Continue Browsing"]) if option == "Cancel Ticket" $g.tickets.delete @@ -46,10 +44,6 @@ def signup end end - - - - def search movies = Movie.all.map {|movie| movie.title} genres = Genre.all.map {|genre| genre.genre} @@ -88,28 +82,21 @@ def search your_ticket = Ticket.create(theater_id: Theater.all.first.id, movie_id: ticket_choice.id, guest_id: $g.id) puts your_ticket puts ("Please save this id for your confirmation number.").colorize(:magenta) - puts "You're going to see a #{ticket_choice.genre.genre}, #{your_ticket.movie.title}, @ #{ticket_choice.showtime} " + puts "You're going to see a #{ticket_choice.genre.genre} movie, #{your_ticket.movie.title}, @ #{ticket_choice.showtime} " end end end - - - - -####how to save rat def thanks - puts "Thank you for your purchase! Commando Theater is b.y.o.b so feel free and WELCOME to bring your own refreshments. We cant wait to watch a movie with you!" + puts "Thank you for your purchase! We cant wait to watch a movie with you!" prompt = TTY::Prompt.new thanks_choice = prompt.ask("Please leave us a rating from 1-5") puts ("Thank you for your feedback!").colorize(:yellow) - # puts "Here are your Commando login credentials. Username: #{$new_username} Password: #{$new_password}. We hope to see you again soon!" - end - + end welcome signup search -thanks +thanks \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index ed6d59ee..c5f1a5a9 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,8 +4,6 @@ Movie.destroy_all Ticket.destroy_all - - commando=Theater.create(name: "Commando Theater") rom_com=Genre.create(genre: ("Romantic Comedy").colorize(:cyan)) @@ -13,7 +11,6 @@ sci_fi=Genre.create(genre: ("Science Fiction").colorize(:cyan)) slasher=Genre.create(genre: ("Slasher").colorize(:cyan)) -donovan = Guest.create(name: "theater", password: "123") g1=Guest.create(name: "Hadi", password: "123") g2=Guest.create(name: "Donovan", password: "123") g3=Guest.create(name: "Drake", password: "123")