From b188b6517780e2cd833e506ff7d82ebd4de670e0 Mon Sep 17 00:00:00 2001
From: vioif
Date: Tue, 23 Jan 2018 15:53:28 -0500
Subject: [PATCH 01/30] added controllers (reservation, restaurant and user)
---
Gemfile | 2 +-
Gemfile.lock | 178 +++++++++---------
app/assets/javascripts/reservation.coffee | 3 +
app/assets/javascripts/restaurant.coffee | 3 +
app/assets/javascripts/user.coffee | 3 +
app/assets/stylesheets/reservation.scss | 3 +
app/assets/stylesheets/restaurant.scss | 3 +
app/assets/stylesheets/user.scss | 3 +
app/controllers/reservation_controller.rb | 2 +
app/controllers/restaurant_controller.rb | 2 +
app/controllers/user_controller.rb | 2 +
app/helpers/reservation_helper.rb | 2 +
app/helpers/restaurant_helper.rb | 2 +
app/helpers/user_helper.rb | 2 +
config/routes.rb | 2 +
.../reservation_controller_test.rb | 7 +
.../controllers/restaurant_controller_test.rb | 7 +
test/controllers/user_controller_test.rb | 7 +
18 files changed, 148 insertions(+), 85 deletions(-)
create mode 100644 app/assets/javascripts/reservation.coffee
create mode 100644 app/assets/javascripts/restaurant.coffee
create mode 100644 app/assets/javascripts/user.coffee
create mode 100644 app/assets/stylesheets/reservation.scss
create mode 100644 app/assets/stylesheets/restaurant.scss
create mode 100644 app/assets/stylesheets/user.scss
create mode 100644 app/controllers/reservation_controller.rb
create mode 100644 app/controllers/restaurant_controller.rb
create mode 100644 app/controllers/user_controller.rb
create mode 100644 app/helpers/reservation_helper.rb
create mode 100644 app/helpers/restaurant_helper.rb
create mode 100644 app/helpers/user_helper.rb
create mode 100644 test/controllers/reservation_controller_test.rb
create mode 100644 test/controllers/restaurant_controller_test.rb
create mode 100644 test/controllers/user_controller_test.rb
diff --git a/Gemfile b/Gemfile
index fecd89c7..0e2e3a92 100644
--- a/Gemfile
+++ b/Gemfile
@@ -33,6 +33,7 @@ gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
+ gem 'awesome_print'
end
group :development do
@@ -42,4 +43,3 @@ group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
-
diff --git a/Gemfile.lock b/Gemfile.lock
index c701ada1..d39e425d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,115 +1,124 @@
GEM
remote: https://rubygems.org/
specs:
- actioncable (5.0.0.1)
- actionpack (= 5.0.0.1)
- nio4r (~> 1.2)
+ actioncable (5.0.6)
+ actionpack (= 5.0.6)
+ nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
- actionmailer (5.0.0.1)
- actionpack (= 5.0.0.1)
- actionview (= 5.0.0.1)
- activejob (= 5.0.0.1)
+ actionmailer (5.0.6)
+ actionpack (= 5.0.6)
+ actionview (= 5.0.6)
+ activejob (= 5.0.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
- actionpack (5.0.0.1)
- actionview (= 5.0.0.1)
- activesupport (= 5.0.0.1)
+ actionpack (5.0.6)
+ actionview (= 5.0.6)
+ activesupport (= 5.0.6)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
- actionview (5.0.0.1)
- activesupport (= 5.0.0.1)
+ actionview (5.0.6)
+ activesupport (= 5.0.6)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
- activejob (5.0.0.1)
- activesupport (= 5.0.0.1)
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
+ activejob (5.0.6)
+ activesupport (= 5.0.6)
globalid (>= 0.3.6)
- activemodel (5.0.0.1)
- activesupport (= 5.0.0.1)
- activerecord (5.0.0.1)
- activemodel (= 5.0.0.1)
- activesupport (= 5.0.0.1)
+ activemodel (5.0.6)
+ activesupport (= 5.0.6)
+ activerecord (5.0.6)
+ activemodel (= 5.0.6)
+ activesupport (= 5.0.6)
arel (~> 7.0)
- activesupport (5.0.0.1)
+ activesupport (5.0.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
- binding_of_caller (0.7.2)
+ awesome_print (1.8.0)
+ binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
- builder (3.2.2)
- byebug (9.0.6)
+ builder (3.2.3)
+ byebug (9.1.0)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
coffee-script (2.4.1)
coffee-script-source
execjs
- coffee-script-source (1.10.0)
- concurrent-ruby (1.0.2)
- debug_inspector (0.0.2)
+ coffee-script-source (1.12.2)
+ concurrent-ruby (1.0.5)
+ crass (1.0.3)
+ debug_inspector (0.0.3)
erubis (2.7.0)
execjs (2.7.0)
- globalid (0.3.7)
- activesupport (>= 4.1.0)
- i18n (0.7.0)
- jbuilder (2.6.0)
- activesupport (>= 3.0.0, < 5.1)
- multi_json (~> 1.2)
- jquery-rails (4.2.1)
+ ffi (1.9.18)
+ globalid (0.4.1)
+ activesupport (>= 4.2.0)
+ i18n (0.9.3)
+ concurrent-ruby (~> 1.0)
+ jbuilder (2.7.0)
+ activesupport (>= 4.2.0)
+ multi_json (>= 1.2)
+ jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
- json (1.8.3)
- loofah (2.0.3)
+ json (1.8.6)
+ loofah (2.1.1)
+ crass (~> 1.0.2)
nokogiri (>= 1.5.9)
- mail (2.6.4)
- mime-types (>= 1.16, < 4)
- method_source (0.8.2)
- mime-types (3.1)
- mime-types-data (~> 3.2015)
- mime-types-data (3.2016.0521)
- mini_portile2 (2.1.0)
- minitest (5.9.1)
- multi_json (1.12.1)
- nio4r (1.2.1)
- nokogiri (1.6.8.1)
- mini_portile2 (~> 2.1.0)
- rack (2.0.1)
+ mail (2.7.0)
+ mini_mime (>= 0.1.1)
+ method_source (0.9.0)
+ mini_mime (1.0.0)
+ mini_portile2 (2.3.0)
+ minitest (5.11.1)
+ multi_json (1.13.1)
+ nio4r (2.2.0)
+ nokogiri (1.8.1)
+ mini_portile2 (~> 2.3.0)
+ rack (2.0.3)
rack-test (0.6.3)
rack (>= 1.0)
- rails (5.0.0.1)
- actioncable (= 5.0.0.1)
- actionmailer (= 5.0.0.1)
- actionpack (= 5.0.0.1)
- actionview (= 5.0.0.1)
- activejob (= 5.0.0.1)
- activemodel (= 5.0.0.1)
- activerecord (= 5.0.0.1)
- activesupport (= 5.0.0.1)
- bundler (>= 1.3.0, < 2.0)
- railties (= 5.0.0.1)
+ rails (5.0.6)
+ actioncable (= 5.0.6)
+ actionmailer (= 5.0.6)
+ actionpack (= 5.0.6)
+ actionview (= 5.0.6)
+ activejob (= 5.0.6)
+ activemodel (= 5.0.6)
+ activerecord (= 5.0.6)
+ activesupport (= 5.0.6)
+ bundler (>= 1.3.0)
+ railties (= 5.0.6)
sprockets-rails (>= 2.0.0)
- rails-dom-testing (2.0.1)
- activesupport (>= 4.2.0, < 6.0)
- nokogiri (~> 1.6.0)
+ rails-dom-testing (2.0.3)
+ activesupport (>= 4.2.0)
+ nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
- railties (5.0.0.1)
- actionpack (= 5.0.0.1)
- activesupport (= 5.0.0.1)
+ railties (5.0.6)
+ actionpack (= 5.0.6)
+ activesupport (= 5.0.6)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
- rake (11.3.0)
- rdoc (4.2.2)
- json (~> 1.4)
- sass (3.4.22)
- sass-rails (5.0.6)
+ rake (12.3.0)
+ rb-fsevent (0.10.2)
+ rb-inotify (0.9.10)
+ ffi (>= 0.5.0, < 2)
+ rdoc (4.3.0)
+ sass (3.5.5)
+ sass-listen (~> 4.0.0)
+ sass-listen (4.0.0)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
+ sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
@@ -118,41 +127,42 @@ GEM
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
- spring (2.0.0)
+ spring (2.0.2)
activesupport (>= 4.2)
- sprockets (3.7.0)
+ sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
- sprockets-rails (3.2.0)
+ sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
- sqlite3 (1.3.12)
- thor (0.19.1)
- thread_safe (0.3.5)
- tilt (2.0.5)
- tzinfo (1.2.2)
+ sqlite3 (1.3.13)
+ thor (0.20.0)
+ thread_safe (0.3.6)
+ tilt (2.0.8)
+ tzinfo (1.2.4)
thread_safe (~> 0.1)
- uglifier (3.0.3)
+ uglifier (4.1.4)
execjs (>= 0.3.0, < 3)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
- websocket-driver (0.6.4)
+ websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
- websocket-extensions (0.1.2)
+ websocket-extensions (0.1.3)
PLATFORMS
ruby
DEPENDENCIES
+ awesome_print
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
- rails (~> 5.0)
+ rails (~> 5.0.1)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
@@ -161,4 +171,4 @@ DEPENDENCIES
web-console (~> 2.0)
BUNDLED WITH
- 1.11.2
+ 1.16.1
diff --git a/app/assets/javascripts/reservation.coffee b/app/assets/javascripts/reservation.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/reservation.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/restaurant.coffee b/app/assets/javascripts/restaurant.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/restaurant.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/user.coffee b/app/assets/javascripts/user.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/user.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/stylesheets/reservation.scss b/app/assets/stylesheets/reservation.scss
new file mode 100644
index 00000000..05e7fc07
--- /dev/null
+++ b/app/assets/stylesheets/reservation.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the reservation controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/restaurant.scss b/app/assets/stylesheets/restaurant.scss
new file mode 100644
index 00000000..294c9da4
--- /dev/null
+++ b/app/assets/stylesheets/restaurant.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the restaurant controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/user.scss b/app/assets/stylesheets/user.scss
new file mode 100644
index 00000000..7c5eca9c
--- /dev/null
+++ b/app/assets/stylesheets/user.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the user controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/reservation_controller.rb b/app/controllers/reservation_controller.rb
new file mode 100644
index 00000000..e4091157
--- /dev/null
+++ b/app/controllers/reservation_controller.rb
@@ -0,0 +1,2 @@
+class ReservationController < ApplicationController
+end
diff --git a/app/controllers/restaurant_controller.rb b/app/controllers/restaurant_controller.rb
new file mode 100644
index 00000000..17af6fc0
--- /dev/null
+++ b/app/controllers/restaurant_controller.rb
@@ -0,0 +1,2 @@
+class RestaurantController < ApplicationController
+end
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
new file mode 100644
index 00000000..11046fdf
--- /dev/null
+++ b/app/controllers/user_controller.rb
@@ -0,0 +1,2 @@
+class UserController < ApplicationController
+end
diff --git a/app/helpers/reservation_helper.rb b/app/helpers/reservation_helper.rb
new file mode 100644
index 00000000..a7eb8525
--- /dev/null
+++ b/app/helpers/reservation_helper.rb
@@ -0,0 +1,2 @@
+module ReservationHelper
+end
diff --git a/app/helpers/restaurant_helper.rb b/app/helpers/restaurant_helper.rb
new file mode 100644
index 00000000..fbcf5e31
--- /dev/null
+++ b/app/helpers/restaurant_helper.rb
@@ -0,0 +1,2 @@
+module RestaurantHelper
+end
diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb
new file mode 100644
index 00000000..0147c3fe
--- /dev/null
+++ b/app/helpers/user_helper.rb
@@ -0,0 +1,2 @@
+module UserHelper
+end
diff --git a/config/routes.rb b/config/routes.rb
index 787824f8..a59c7a48 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,3 +1,5 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+
+
end
diff --git a/test/controllers/reservation_controller_test.rb b/test/controllers/reservation_controller_test.rb
new file mode 100644
index 00000000..b67b97d4
--- /dev/null
+++ b/test/controllers/reservation_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ReservationControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/controllers/restaurant_controller_test.rb b/test/controllers/restaurant_controller_test.rb
new file mode 100644
index 00000000..ed137da8
--- /dev/null
+++ b/test/controllers/restaurant_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class RestaurantControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/controllers/user_controller_test.rb b/test/controllers/user_controller_test.rb
new file mode 100644
index 00000000..314cd5a4
--- /dev/null
+++ b/test/controllers/user_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UserControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
From aef70b841b50b290897fc3a6d3549887e57870f6 Mon Sep 17 00:00:00 2001
From: vioif
Date: Tue, 23 Jan 2018 16:07:52 -0500
Subject: [PATCH 02/30] added sessions controller androutes (user, reservation
and resturant)
---
app/assets/javascripts/sessions.coffee | 3 +
app/assets/stylesheets/sessions.scss | 3 +
app/controllers/sessions_controller.rb | 2 +
app/helpers/sessions_helper.rb | 2 +
config/routes.rb | 58 +++++++++++++++++++-
test/controllers/sessions_controller_test.rb | 7 +++
6 files changed, 74 insertions(+), 1 deletion(-)
create mode 100644 app/assets/javascripts/sessions.coffee
create mode 100644 app/assets/stylesheets/sessions.scss
create mode 100644 app/controllers/sessions_controller.rb
create mode 100644 app/helpers/sessions_helper.rb
create mode 100644 test/controllers/sessions_controller_test.rb
diff --git a/app/assets/javascripts/sessions.coffee b/app/assets/javascripts/sessions.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/sessions.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/stylesheets/sessions.scss b/app/assets/stylesheets/sessions.scss
new file mode 100644
index 00000000..7bef9cf8
--- /dev/null
+++ b/app/assets/stylesheets/sessions.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the sessions controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
new file mode 100644
index 00000000..16d11b57
--- /dev/null
+++ b/app/controllers/sessions_controller.rb
@@ -0,0 +1,2 @@
+class SessionsController < ApplicationController
+end
diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb
new file mode 100644
index 00000000..309f8b2e
--- /dev/null
+++ b/app/helpers/sessions_helper.rb
@@ -0,0 +1,2 @@
+module SessionsHelper
+end
diff --git a/config/routes.rb b/config/routes.rb
index a59c7a48..c1a3caba 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,61 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
-
+ root 'resturants#index'
+
+ get 'resturants' => 'resturants#index'
+
+ post 'resturants' => 'resturants#create'
+ get 'resturants/new' => 'resturants#new'
+
+ get 'resturants/:id' => 'resturants#show'
+
+ get 'resturants/:id/edit' => "resturants#edit"
+ patch 'resturants/:id' => "resturants#update"
+
+ delete 'resturants/:id' => 'resturants#destroy'
+
+
+ get 'sessions/new' => 'sessions#new'
+ post 'sessions/create' => 'sessions#create'
+
+# User
+ root 'users#index'
+
+ get 'users' => 'users#index'
+
+ post 'users' => 'users#create'
+ get 'users/new' => 'users#new'
+
+ get 'users/:id' => 'resturants#show'
+
+ get 'users/:id/edit' => "users#edit"
+ patch 'users/:id' => "users#update"
+
+ delete 'users/:id' => 'users#destroy'
+
+# Reservations
+ get 'reservations/new' => 'reservations#new'
+ post 'reservations/create' => 'reservations#create'
+
+ root 'reservations#index'
+
+ get 'reservations' => 'reservations#index'
+
+ post 'reservations' => 'reservations#create'
+ get 'reservations/new' => 'reservations#new'
+
+ get 'reservations/:id' => 'reservations#show'
+
+ get 'reservations/:id/edit' => "reservations#edit"
+ patch 'reservations/:id' => "reservations#update"
+
+ delete 'reservations/:id' => 'reservations#destroy'
+
+
+ get 'sessions/new' => 'sessions#new'
+ post 'sessions/create' => 'sessions#create'
+
+
+
end
diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb
new file mode 100644
index 00000000..6135ce6a
--- /dev/null
+++ b/test/controllers/sessions_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class SessionsControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
From 85901efdfaa5e260842bb0125add241a2bbdd038 Mon Sep 17 00:00:00 2001
From: "paulcosta2001@gmail.com"
Date: Tue, 23 Jan 2018 16:11:22 -0500
Subject: [PATCH 03/30] html create1
---
Gemfile | 3 +-
Gemfile.lock | 178 +++++++++++++++++++++++++++------------------------
2 files changed, 96 insertions(+), 85 deletions(-)
diff --git a/Gemfile b/Gemfile
index fecd89c7..81c96fb4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -33,13 +33,14 @@ gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
+ gem 'awesome_print'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
-
diff --git a/Gemfile.lock b/Gemfile.lock
index c701ada1..0f724a7a 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,115 +1,124 @@
GEM
remote: https://rubygems.org/
specs:
- actioncable (5.0.0.1)
- actionpack (= 5.0.0.1)
- nio4r (~> 1.2)
+ actioncable (5.0.6)
+ actionpack (= 5.0.6)
+ nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
- actionmailer (5.0.0.1)
- actionpack (= 5.0.0.1)
- actionview (= 5.0.0.1)
- activejob (= 5.0.0.1)
+ actionmailer (5.0.6)
+ actionpack (= 5.0.6)
+ actionview (= 5.0.6)
+ activejob (= 5.0.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
- actionpack (5.0.0.1)
- actionview (= 5.0.0.1)
- activesupport (= 5.0.0.1)
+ actionpack (5.0.6)
+ actionview (= 5.0.6)
+ activesupport (= 5.0.6)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
- actionview (5.0.0.1)
- activesupport (= 5.0.0.1)
+ actionview (5.0.6)
+ activesupport (= 5.0.6)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 2.0)
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
- activejob (5.0.0.1)
- activesupport (= 5.0.0.1)
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
+ activejob (5.0.6)
+ activesupport (= 5.0.6)
globalid (>= 0.3.6)
- activemodel (5.0.0.1)
- activesupport (= 5.0.0.1)
- activerecord (5.0.0.1)
- activemodel (= 5.0.0.1)
- activesupport (= 5.0.0.1)
+ activemodel (5.0.6)
+ activesupport (= 5.0.6)
+ activerecord (5.0.6)
+ activemodel (= 5.0.6)
+ activesupport (= 5.0.6)
arel (~> 7.0)
- activesupport (5.0.0.1)
+ activesupport (5.0.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
- binding_of_caller (0.7.2)
+ awesome_print (1.8.0)
+ binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
- builder (3.2.2)
- byebug (9.0.6)
+ builder (3.2.3)
+ byebug (9.1.0)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
coffee-script (2.4.1)
coffee-script-source
execjs
- coffee-script-source (1.10.0)
- concurrent-ruby (1.0.2)
- debug_inspector (0.0.2)
+ coffee-script-source (1.12.2)
+ concurrent-ruby (1.0.5)
+ crass (1.0.3)
+ debug_inspector (0.0.3)
erubis (2.7.0)
execjs (2.7.0)
- globalid (0.3.7)
- activesupport (>= 4.1.0)
- i18n (0.7.0)
- jbuilder (2.6.0)
- activesupport (>= 3.0.0, < 5.1)
- multi_json (~> 1.2)
- jquery-rails (4.2.1)
+ ffi (1.9.18)
+ globalid (0.4.1)
+ activesupport (>= 4.2.0)
+ i18n (0.9.3)
+ concurrent-ruby (~> 1.0)
+ jbuilder (2.7.0)
+ activesupport (>= 4.2.0)
+ multi_json (>= 1.2)
+ jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
- json (1.8.3)
- loofah (2.0.3)
+ json (1.8.6)
+ loofah (2.1.1)
+ crass (~> 1.0.2)
nokogiri (>= 1.5.9)
- mail (2.6.4)
- mime-types (>= 1.16, < 4)
- method_source (0.8.2)
- mime-types (3.1)
- mime-types-data (~> 3.2015)
- mime-types-data (3.2016.0521)
- mini_portile2 (2.1.0)
- minitest (5.9.1)
- multi_json (1.12.1)
- nio4r (1.2.1)
- nokogiri (1.6.8.1)
- mini_portile2 (~> 2.1.0)
- rack (2.0.1)
+ mail (2.7.0)
+ mini_mime (>= 0.1.1)
+ method_source (0.9.0)
+ mini_mime (1.0.0)
+ mini_portile2 (2.3.0)
+ minitest (5.11.1)
+ multi_json (1.13.1)
+ nio4r (2.2.0)
+ nokogiri (1.8.1)
+ mini_portile2 (~> 2.3.0)
+ rack (2.0.3)
rack-test (0.6.3)
rack (>= 1.0)
- rails (5.0.0.1)
- actioncable (= 5.0.0.1)
- actionmailer (= 5.0.0.1)
- actionpack (= 5.0.0.1)
- actionview (= 5.0.0.1)
- activejob (= 5.0.0.1)
- activemodel (= 5.0.0.1)
- activerecord (= 5.0.0.1)
- activesupport (= 5.0.0.1)
- bundler (>= 1.3.0, < 2.0)
- railties (= 5.0.0.1)
+ rails (5.0.6)
+ actioncable (= 5.0.6)
+ actionmailer (= 5.0.6)
+ actionpack (= 5.0.6)
+ actionview (= 5.0.6)
+ activejob (= 5.0.6)
+ activemodel (= 5.0.6)
+ activerecord (= 5.0.6)
+ activesupport (= 5.0.6)
+ bundler (>= 1.3.0)
+ railties (= 5.0.6)
sprockets-rails (>= 2.0.0)
- rails-dom-testing (2.0.1)
- activesupport (>= 4.2.0, < 6.0)
- nokogiri (~> 1.6.0)
+ rails-dom-testing (2.0.3)
+ activesupport (>= 4.2.0)
+ nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
- railties (5.0.0.1)
- actionpack (= 5.0.0.1)
- activesupport (= 5.0.0.1)
+ railties (5.0.6)
+ actionpack (= 5.0.6)
+ activesupport (= 5.0.6)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
- rake (11.3.0)
- rdoc (4.2.2)
- json (~> 1.4)
- sass (3.4.22)
- sass-rails (5.0.6)
+ rake (12.3.0)
+ rb-fsevent (0.10.2)
+ rb-inotify (0.9.10)
+ ffi (>= 0.5.0, < 2)
+ rdoc (4.3.0)
+ sass (3.5.5)
+ sass-listen (~> 4.0.0)
+ sass-listen (4.0.0)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
+ sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
@@ -118,41 +127,42 @@ GEM
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
- spring (2.0.0)
+ spring (2.0.2)
activesupport (>= 4.2)
- sprockets (3.7.0)
+ sprockets (3.7.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
- sprockets-rails (3.2.0)
+ sprockets-rails (3.2.1)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
- sqlite3 (1.3.12)
- thor (0.19.1)
- thread_safe (0.3.5)
- tilt (2.0.5)
- tzinfo (1.2.2)
+ sqlite3 (1.3.13)
+ thor (0.20.0)
+ thread_safe (0.3.6)
+ tilt (2.0.8)
+ tzinfo (1.2.4)
thread_safe (~> 0.1)
- uglifier (3.0.3)
+ uglifier (4.1.4)
execjs (>= 0.3.0, < 3)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
- websocket-driver (0.6.4)
+ websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
- websocket-extensions (0.1.2)
+ websocket-extensions (0.1.3)
PLATFORMS
ruby
DEPENDENCIES
+ awesome_print
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
- rails (~> 5.0)
+ rails (~> 5.0.1)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
@@ -161,4 +171,4 @@ DEPENDENCIES
web-console (~> 2.0)
BUNDLED WITH
- 1.11.2
+ 1.16.0
From 54fd0bda6f2949ffdacb963b359c05a91676d6c2 Mon Sep 17 00:00:00 2001
From: vioif
Date: Tue, 23 Jan 2018 16:30:29 -0500
Subject: [PATCH 04/30] views added folders (rsv, rst, session and user)
---
app/views/reservation/index.html.erb | 0
app/views/restaurant/index.html.erb | 0
app/views/sessions/indec.html.erb | 0
app/views/user/index.html.erb | 0
4 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 app/views/reservation/index.html.erb
create mode 100644 app/views/restaurant/index.html.erb
create mode 100644 app/views/sessions/indec.html.erb
create mode 100644 app/views/user/index.html.erb
diff --git a/app/views/reservation/index.html.erb b/app/views/reservation/index.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/restaurant/index.html.erb b/app/views/restaurant/index.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/sessions/indec.html.erb b/app/views/sessions/indec.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/user/index.html.erb b/app/views/user/index.html.erb
new file mode 100644
index 00000000..e69de29b
From 9bcc79d3deba3d45619732760a119e0f1cce7528 Mon Sep 17 00:00:00 2001
From: vioif
Date: Tue, 23 Jan 2018 19:21:23 -0500
Subject: [PATCH 05/30] fixed controllers and now users view function is
working
---
Gemfile | 2 +-
Gemfile.lock | 2 +
app/controllers/reservation_controller.rb | 2 -
app/controllers/reservations_controller.rb | 2 +
app/controllers/restaurant_controller.rb | 2 -
app/controllers/restaurants_controller.rb | 2 +
app/controllers/user_controller.rb | 2 -
app/controllers/users_controller.rb | 24 ++++++
app/models/user.rb | 3 +
.../index.html.erb | 0
app/views/user/index.html.erb | 0
app/views/users/new.html.erb | 33 ++++++++
config/routes.rb | 79 ++++++++-----------
db/migrate/20180123222244_create_users.rb | 13 +++
db/schema.rb | 24 ++++++
test/fixtures/users.yml | 11 +++
test/models/user_test.rb | 7 ++
17 files changed, 157 insertions(+), 51 deletions(-)
delete mode 100644 app/controllers/reservation_controller.rb
create mode 100644 app/controllers/reservations_controller.rb
delete mode 100644 app/controllers/restaurant_controller.rb
create mode 100644 app/controllers/restaurants_controller.rb
delete mode 100644 app/controllers/user_controller.rb
create mode 100644 app/controllers/users_controller.rb
create mode 100644 app/models/user.rb
rename app/views/{restaurant => restaurants}/index.html.erb (100%)
delete mode 100644 app/views/user/index.html.erb
create mode 100644 app/views/users/new.html.erb
create mode 100644 db/migrate/20180123222244_create_users.rb
create mode 100644 db/schema.rb
create mode 100644 test/fixtures/users.yml
create mode 100644 test/models/user_test.rb
diff --git a/Gemfile b/Gemfile
index 0e2e3a92..049ad1ea 100644
--- a/Gemfile
+++ b/Gemfile
@@ -22,7 +22,7 @@ gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
-# gem 'bcrypt', '~> 3.1.7'
+gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
diff --git a/Gemfile.lock b/Gemfile.lock
index d39e425d..8f4faa5f 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -40,6 +40,7 @@ GEM
tzinfo (~> 1.1)
arel (7.1.4)
awesome_print (1.8.0)
+ bcrypt (3.1.11)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
builder (3.2.3)
@@ -158,6 +159,7 @@ PLATFORMS
DEPENDENCIES
awesome_print
+ bcrypt (~> 3.1.7)
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
diff --git a/app/controllers/reservation_controller.rb b/app/controllers/reservation_controller.rb
deleted file mode 100644
index e4091157..00000000
--- a/app/controllers/reservation_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class ReservationController < ApplicationController
-end
diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb
new file mode 100644
index 00000000..ca9e57fc
--- /dev/null
+++ b/app/controllers/reservations_controller.rb
@@ -0,0 +1,2 @@
+class ReservationsController < ApplicationController
+end
diff --git a/app/controllers/restaurant_controller.rb b/app/controllers/restaurant_controller.rb
deleted file mode 100644
index 17af6fc0..00000000
--- a/app/controllers/restaurant_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class RestaurantController < ApplicationController
-end
diff --git a/app/controllers/restaurants_controller.rb b/app/controllers/restaurants_controller.rb
new file mode 100644
index 00000000..3265ef85
--- /dev/null
+++ b/app/controllers/restaurants_controller.rb
@@ -0,0 +1,2 @@
+class RestaurantsController < ApplicationController
+end
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
deleted file mode 100644
index 11046fdf..00000000
--- a/app/controllers/user_controller.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class UserController < ApplicationController
-end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
new file mode 100644
index 00000000..7f488718
--- /dev/null
+++ b/app/controllers/users_controller.rb
@@ -0,0 +1,24 @@
+class UsersController < ApplicationController
+
+ def new
+ @user = User.new
+ end
+
+ def create
+ @user = User.new
+ @user.name = params[:user][:name]
+ @user.email = params[:user][:email]
+ @user.password = params[:user][:password]
+ @user.password_confirmation = params[:user][:password_confirmation]
+ @user.phone_number = params[:user][:phone_number]
+
+ puts "********"
+ p @user
+
+ if @user.save
+ redirect_to users_url
+ else
+ render :new
+ end
+ end
+end
diff --git a/app/models/user.rb b/app/models/user.rb
new file mode 100644
index 00000000..987cde92
--- /dev/null
+++ b/app/models/user.rb
@@ -0,0 +1,3 @@
+class User < ApplicationRecord
+ has_secure_password
+end
diff --git a/app/views/restaurant/index.html.erb b/app/views/restaurants/index.html.erb
similarity index 100%
rename from app/views/restaurant/index.html.erb
rename to app/views/restaurants/index.html.erb
diff --git a/app/views/user/index.html.erb b/app/views/user/index.html.erb
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
new file mode 100644
index 00000000..fb6e52bf
--- /dev/null
+++ b/app/views/users/new.html.erb
@@ -0,0 +1,33 @@
+Create New User
+
+<%= form_for @user do |f| %>
+
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+
+
+
+ <%= f.label :email %>
+ <%= f.email_field :email %>
+
+
+
+ <%= f.label :password %>
+ <%= f.password_field :password %>
+
+
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+
+
+
+ <%= f.label :phone_number %>
+ <%= f.text_field :phone_number %>
+
+
+ <%= f.submit 'Sign Up' %>
+
+<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index c1a3caba..7bd468d8 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,60 +2,51 @@
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'resturants#index'
+ resources :resturants
- get 'resturants' => 'resturants#index'
-
- post 'resturants' => 'resturants#create'
- get 'resturants/new' => 'resturants#new'
-
- get 'resturants/:id' => 'resturants#show'
-
- get 'resturants/:id/edit' => "resturants#edit"
- patch 'resturants/:id' => "resturants#update"
-
- delete 'resturants/:id' => 'resturants#destroy'
+ # get 'resturants' => 'resturants#index'
+ #
+ # post 'resturants' => 'resturants#create'
+ # get 'resturants/new' => 'resturants#new'
+ #
+ # get 'resturants/:id' => 'resturants#show'
+ #
+ # get 'resturants/:id/edit' => "resturants#edit"
+ # patch 'resturants/:id' => "resturants#update"
+ #
+ # delete 'resturants/:id' => 'resturants#destroy'
get 'sessions/new' => 'sessions#new'
post 'sessions/create' => 'sessions#create'
# User
- root 'users#index'
-
- get 'users' => 'users#index'
-
- post 'users' => 'users#create'
- get 'users/new' => 'users#new'
-
- get 'users/:id' => 'resturants#show'
-
- get 'users/:id/edit' => "users#edit"
- patch 'users/:id' => "users#update"
-
- delete 'users/:id' => 'users#destroy'
+ resources :users
# Reservations
- get 'reservations/new' => 'reservations#new'
- post 'reservations/create' => 'reservations#create'
-
- root 'reservations#index'
-
- get 'reservations' => 'reservations#index'
-
- post 'reservations' => 'reservations#create'
- get 'reservations/new' => 'reservations#new'
-
- get 'reservations/:id' => 'reservations#show'
-
- get 'reservations/:id/edit' => "reservations#edit"
- patch 'reservations/:id' => "reservations#update"
-
- delete 'reservations/:id' => 'reservations#destroy'
-
-
- get 'sessions/new' => 'sessions#new'
- post 'sessions/create' => 'sessions#create'
+ resources :reservations
+ # get 'reservations/new' => 'reservations#new'
+ # post 'reservations/create' => 'reservations#create'
+ #
+ # root 'reservations#index'
+ #
+ # get 'reservations' => 'reservations#index'
+ #
+ # post 'reservations' => 'reservations#create'
+ # get 'reservations/new' => 'reservations#new'
+ #
+ # get 'reservations/:id' => 'reservations#show'
+ #
+ # get 'reservations/:id/edit' => "reservations#edit"
+ # patch 'reservations/:id' => "reservations#update"
+ #
+ # delete 'reservations/:id' => 'reservations#destroy'
+ #
+ #
+ # get 'sessions/new' => 'sessions#new'
+ # post 'sessions/create' => 'sessions#create'
+ #
end
diff --git a/db/migrate/20180123222244_create_users.rb b/db/migrate/20180123222244_create_users.rb
new file mode 100644
index 00000000..def5e913
--- /dev/null
+++ b/db/migrate/20180123222244_create_users.rb
@@ -0,0 +1,13 @@
+class CreateUsers < ActiveRecord::Migration[5.0]
+ def change
+ create_table :users do |t|
+
+ t.string :name
+ t.string :password_digest
+ t.string :email
+ t.string :phone_number
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 00000000..dbb29380
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,24 @@
+# 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.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 20180123222244) do
+
+ create_table "users", force: :cascade do |t|
+ t.string "name"
+ t.string "password_digest"
+ t.string "email"
+ t.string "phone_number"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+end
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
new file mode 100644
index 00000000..80aed36e
--- /dev/null
+++ b/test/fixtures/users.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
new file mode 100644
index 00000000..82f61e01
--- /dev/null
+++ b/test/models/user_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UserTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
From 534f2ddc361fc7eedca36281e4aa8fefa760de74 Mon Sep 17 00:00:00 2001
From: "paulcosta2001@gmail.com"
Date: Wed, 24 Jan 2018 09:58:03 -0500
Subject: [PATCH 06/30] restaurant views current, form, edit
---
.../form_reservation.html.erb} | 0
app/views/reservation/new.html.erb | 0
app/views/reservation/show.html.erb | 0
.../reservation/user_loyalty_points.html.erb | 0
.../restaurant/_current_restaurant.html.erb | 0
.../restaurant/_form_restaurant.html.erb | 49 +++++++++++++++++++
app/views/restaurant/edit.html.erb | 0
app/views/restaurant/new.html.erb | 0
app/views/restaurant/show.html.erb | 0
app/views/sessions/sessions.html.erb | 0
app/views/user/edit_username.html.erb | 0
app/views/user/form_username_create.html.erb | 0
app/views/user/new.html.erb | 0
app/views/user/show.html.erb | 0
14 files changed, 49 insertions(+)
rename app/views/{sessions/indec.html.erb => reservation/form_reservation.html.erb} (100%)
create mode 100644 app/views/reservation/new.html.erb
create mode 100644 app/views/reservation/show.html.erb
create mode 100644 app/views/reservation/user_loyalty_points.html.erb
create mode 100644 app/views/restaurant/_current_restaurant.html.erb
create mode 100644 app/views/restaurant/_form_restaurant.html.erb
create mode 100644 app/views/restaurant/edit.html.erb
create mode 100644 app/views/restaurant/new.html.erb
create mode 100644 app/views/restaurant/show.html.erb
create mode 100644 app/views/sessions/sessions.html.erb
create mode 100644 app/views/user/edit_username.html.erb
create mode 100644 app/views/user/form_username_create.html.erb
create mode 100644 app/views/user/new.html.erb
create mode 100644 app/views/user/show.html.erb
diff --git a/app/views/sessions/indec.html.erb b/app/views/reservation/form_reservation.html.erb
similarity index 100%
rename from app/views/sessions/indec.html.erb
rename to app/views/reservation/form_reservation.html.erb
diff --git a/app/views/reservation/new.html.erb b/app/views/reservation/new.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/reservation/show.html.erb b/app/views/reservation/show.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/reservation/user_loyalty_points.html.erb b/app/views/reservation/user_loyalty_points.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/restaurant/_current_restaurant.html.erb b/app/views/restaurant/_current_restaurant.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/restaurant/_form_restaurant.html.erb b/app/views/restaurant/_form_restaurant.html.erb
new file mode 100644
index 00000000..80d6abbf
--- /dev/null
+++ b/app/views/restaurant/_form_restaurant.html.erb
@@ -0,0 +1,49 @@
+<%= form_for @restaurant do |f|%>
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+
+ <%= f.label :cuisine %>
+ <%= f.text_field :cuisine %>
+
+
+ <%= f.label :address %>
+ <%= f.text_field :address%>
+
+
+ <%= f.label :capacity %>
+ <%= f.text_field :capacity%>
+
+
+ <%= f.label :open_time %>
+ <%= f.time_select :open_time,
+ :minute_step =>30,
+ :ampm => true %>
+
+
+ <%= f.label :close_time %>
+ <%= f.time_select :close_time,
+ :minute_step =>30,
+ :ampm => true %>
+
+
+
+ <%= f.label :image_url %>
+ <%= f.text_field :image_url%>
+
+
+ <%= f.submit %>
+
+ <% if restaurant.errors.any? %>
+
+
<%= pluralize(restaurant.errors.count, "error") %> prohibited this product from being saved:
+
+
+ <% restaurant.errors.full_messages.each do |msg| %>
+ - <%= msg %>
+ <% end %>
+
+
+ <% end %>
+<% end %>
diff --git a/app/views/restaurant/edit.html.erb b/app/views/restaurant/edit.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/restaurant/new.html.erb b/app/views/restaurant/new.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/restaurant/show.html.erb b/app/views/restaurant/show.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/sessions/sessions.html.erb b/app/views/sessions/sessions.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/user/edit_username.html.erb b/app/views/user/edit_username.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/user/form_username_create.html.erb b/app/views/user/form_username_create.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/user/new.html.erb b/app/views/user/new.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/app/views/user/show.html.erb b/app/views/user/show.html.erb
new file mode 100644
index 00000000..e69de29b
From cb468a6034c579662f51056c1c04fa4f4b64e787 Mon Sep 17 00:00:00 2001
From: vioif
Date: Wed, 24 Jan 2018 10:47:08 -0500
Subject: [PATCH 07/30] fixed master views application made files plural ie.
restaurants
---
app/views/{reservation => reservations}/form_reservation.html.erb | 0
app/views/{reservation => reservations}/index.html.erb | 0
app/views/{reservation => reservations}/new.html.erb | 0
app/views/{reservation => reservations}/show.html.erb | 0
.../{reservation => reservations}/user_loyalty_points.html.erb | 0
.../{restaurant => restaurants}/_current_restaurant.html.erb | 0
app/views/{restaurant => restaurants}/_form_restaurant.html.erb | 0
app/views/{restaurant => restaurants}/edit.html.erb | 0
app/views/restaurants/index.html.erb | 0
app/views/{restaurant => restaurants}/new.html.erb | 0
app/views/{restaurant => restaurants}/show.html.erb | 0
app/views/user/new.html.erb | 0
app/views/{user => users}/edit_username.html.erb | 0
app/views/{user => users}/form_username_create.html.erb | 0
app/views/{user => users}/show.html.erb | 0
15 files changed, 0 insertions(+), 0 deletions(-)
rename app/views/{reservation => reservations}/form_reservation.html.erb (100%)
rename app/views/{reservation => reservations}/index.html.erb (100%)
rename app/views/{reservation => reservations}/new.html.erb (100%)
rename app/views/{reservation => reservations}/show.html.erb (100%)
rename app/views/{reservation => reservations}/user_loyalty_points.html.erb (100%)
rename app/views/{restaurant => restaurants}/_current_restaurant.html.erb (100%)
rename app/views/{restaurant => restaurants}/_form_restaurant.html.erb (100%)
rename app/views/{restaurant => restaurants}/edit.html.erb (100%)
delete mode 100644 app/views/restaurants/index.html.erb
rename app/views/{restaurant => restaurants}/new.html.erb (100%)
rename app/views/{restaurant => restaurants}/show.html.erb (100%)
delete mode 100644 app/views/user/new.html.erb
rename app/views/{user => users}/edit_username.html.erb (100%)
rename app/views/{user => users}/form_username_create.html.erb (100%)
rename app/views/{user => users}/show.html.erb (100%)
diff --git a/app/views/reservation/form_reservation.html.erb b/app/views/reservations/form_reservation.html.erb
similarity index 100%
rename from app/views/reservation/form_reservation.html.erb
rename to app/views/reservations/form_reservation.html.erb
diff --git a/app/views/reservation/index.html.erb b/app/views/reservations/index.html.erb
similarity index 100%
rename from app/views/reservation/index.html.erb
rename to app/views/reservations/index.html.erb
diff --git a/app/views/reservation/new.html.erb b/app/views/reservations/new.html.erb
similarity index 100%
rename from app/views/reservation/new.html.erb
rename to app/views/reservations/new.html.erb
diff --git a/app/views/reservation/show.html.erb b/app/views/reservations/show.html.erb
similarity index 100%
rename from app/views/reservation/show.html.erb
rename to app/views/reservations/show.html.erb
diff --git a/app/views/reservation/user_loyalty_points.html.erb b/app/views/reservations/user_loyalty_points.html.erb
similarity index 100%
rename from app/views/reservation/user_loyalty_points.html.erb
rename to app/views/reservations/user_loyalty_points.html.erb
diff --git a/app/views/restaurant/_current_restaurant.html.erb b/app/views/restaurants/_current_restaurant.html.erb
similarity index 100%
rename from app/views/restaurant/_current_restaurant.html.erb
rename to app/views/restaurants/_current_restaurant.html.erb
diff --git a/app/views/restaurant/_form_restaurant.html.erb b/app/views/restaurants/_form_restaurant.html.erb
similarity index 100%
rename from app/views/restaurant/_form_restaurant.html.erb
rename to app/views/restaurants/_form_restaurant.html.erb
diff --git a/app/views/restaurant/edit.html.erb b/app/views/restaurants/edit.html.erb
similarity index 100%
rename from app/views/restaurant/edit.html.erb
rename to app/views/restaurants/edit.html.erb
diff --git a/app/views/restaurants/index.html.erb b/app/views/restaurants/index.html.erb
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/views/restaurant/new.html.erb b/app/views/restaurants/new.html.erb
similarity index 100%
rename from app/views/restaurant/new.html.erb
rename to app/views/restaurants/new.html.erb
diff --git a/app/views/restaurant/show.html.erb b/app/views/restaurants/show.html.erb
similarity index 100%
rename from app/views/restaurant/show.html.erb
rename to app/views/restaurants/show.html.erb
diff --git a/app/views/user/new.html.erb b/app/views/user/new.html.erb
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/views/user/edit_username.html.erb b/app/views/users/edit_username.html.erb
similarity index 100%
rename from app/views/user/edit_username.html.erb
rename to app/views/users/edit_username.html.erb
diff --git a/app/views/user/form_username_create.html.erb b/app/views/users/form_username_create.html.erb
similarity index 100%
rename from app/views/user/form_username_create.html.erb
rename to app/views/users/form_username_create.html.erb
diff --git a/app/views/user/show.html.erb b/app/views/users/show.html.erb
similarity index 100%
rename from app/views/user/show.html.erb
rename to app/views/users/show.html.erb
From 326743b2b3739fa081d7f66908636db8caa4590d Mon Sep 17 00:00:00 2001
From: vioif
Date: Wed, 24 Jan 2018 11:26:31 -0500
Subject: [PATCH 08/30] added info into sessions controller and views session
controller. Both functions are not working yet
---
app/controllers/sessions_controller.rb | 19 +++++++++++++++++++
app/views/sessions/new.html.erb | 13 +++++++++++++
app/views/sessions/sessions.html.erb | 0
config/routes.rb | 6 +++---
4 files changed, 35 insertions(+), 3 deletions(-)
create mode 100644 app/views/sessions/new.html.erb
delete mode 100644 app/views/sessions/sessions.html.erb
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 16d11b57..de6b71c5 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,2 +1,21 @@
class SessionsController < ApplicationController
+
+ def new
+ end
+
+ def create
+ user = User.find_by(email: params [:email])
+ if user && user.authenticate(params [:password])
+ session[:user_id] = user.id
+ redirect_to user_url, notice: "Logged in!"
+ else
+ flash[:notice] = "Invalid email or password"
+ render "new"
+ end
+ end
+
+ def destory
+ session[:user_id] = nil
+ redirect_to user_url, notice: "Logged out!"
+ end
end
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
new file mode 100644
index 00000000..f36c98da
--- /dev/null
+++ b/app/views/sessions/new.html.erb
@@ -0,0 +1,13 @@
+Log in
+
+ <%= form_tag 'sessions_path' do %>
+
+ <%= label_tag :email %>
+ <%= text_field_tag :email, params[:email] %>
+
+
+ <%= label_tag :password %>
+ <%= password_field_tag :password %>
+
+ <%= submit_tag "Log in" %>
+<% end %>
diff --git a/app/views/sessions/sessions.html.erb b/app/views/sessions/sessions.html.erb
deleted file mode 100644
index e69de29b..00000000
diff --git a/config/routes.rb b/config/routes.rb
index 7bd468d8..d4367ccc 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -44,9 +44,9 @@
# delete 'reservations/:id' => 'reservations#destroy'
#
#
- # get 'sessions/new' => 'sessions#new'
- # post 'sessions/create' => 'sessions#create'
- #
+ get 'sessions/new' => 'sessions#new'
+ post 'sessions/create' => 'sessions#create'
+
end
From 79ae8dbaf5f82ed7fa37c751b02cb93d39d219a0 Mon Sep 17 00:00:00 2001
From: vioif
Date: Wed, 24 Jan 2018 11:40:07 -0500
Subject: [PATCH 09/30] application controller def current user
---
app/controllers/application_controller.rb | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index d83690e1..51088ccf 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,4 +2,26 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
+
+ private
+
+ def current_user
+ @current_user ||= User.find(session[:user_id]) if session[:user_id]
+ end
+
+ helper_method :current_user
+
+ def ensure_logged_in
+ if !session[:user_id]
+ flash[:alert] = ["You need to be logged in to do that!"]
+ redirect_to new_session_url
+ end
+ end
+
+ def ensure_user_reservation
+ if session[:user_id] != @user.user_id
+ flash[:alert] = ["Would you like to contiune with your reservations?"]
+ redirect_to root_path
+ end
+ end
end
From 589e8a16410a29c2507eb5d939025dc5136ab55c Mon Sep 17 00:00:00 2001
From: vioif
Date: Wed, 24 Jan 2018 12:24:21 -0500
Subject: [PATCH 10/30] reservation controller made nothing in reservations
view yet
---
app/controllers/reservations_controller.rb | 50 ++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb
index ca9e57fc..7405a63a 100644
--- a/app/controllers/reservations_controller.rb
+++ b/app/controllers/reservations_controller.rb
@@ -1,2 +1,52 @@
class ReservationsController < ApplicationController
+
+ def index
+ @reservations = Reservations.all
+ end
+
+ def show
+ @resevation = Reservation.find(params[:id])
+ end
+
+ def new
+ @reservation = Reservation.new
+ end
+
+ def edit
+ @resevation = Reservation.find(params[:id])
+ end
+
+ def create
+ @reservaiton = Reservation.new
+
+ @reservaiton.name = params[:reservation][:name]
+ @reservaiton.date = params[:reservation][:date]
+ @reservaiton.number_of_people = params[:reservation][:number_of_people]
+
+ if @resevation.save
+ redirect_to resturants_path, notice: 'Resevations have succesfully been booked'
+ else
+ render 'resturants'
+ end
+ end
+
+ def update
+ @reservation = Reservation.find(params[:id])
+
+ @reservaiton.name = params[:reservation][:name]
+ @reservaiton.date = params[:reservation][:date]
+ @reservaiton.number_of_people = params[:reservation][:number_of_people]
+
+ if @resevation.save
+ redirect_to resturants_path, notice: 'Resevations have succesfully been updated '
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @reservaiton = Reservation.find(params[:id])
+ @reservaiton.destory
+ redirect_to "/resturants"
+ end
end
From 95de2d1385729ff89b786545c6e3746d00344bdb Mon Sep 17 00:00:00 2001
From: vioif
Date: Wed, 24 Jan 2018 13:40:18 -0500
Subject: [PATCH 11/30] added models (ie. rst, rsv, owner, user) fixed
resevations controller
---
app/controllers/application_controller.rb | 1 +
app/controllers/reservations_controller.rb | 8 ++---
app/models/owner.rb | 2 ++
app/models/reservation.rb | 2 ++
app/models/restaurant.rb | 2 ++
app/views/reservations/index.html.erb | 10 ++++++
app/views/reservations/new.html.erb | 32 +++++++++++++++++++
app/views/sessions/sessions.html.erb | 0
config/routes.rb | 6 ++--
.../20180124180823_create_reservations.rb | 13 ++++++++
.../20180124182405_create_restaurants.rb | 16 ++++++++++
db/migrate/20180124182711_create_owners.rb | 13 ++++++++
db/schema.rb | 31 +++++++++++++++++-
test/fixtures/owners.yml | 11 +++++++
test/fixtures/reservations.yml | 11 +++++++
test/fixtures/restaurants.yml | 11 +++++++
test/models/owner_test.rb | 7 ++++
test/models/reservation_test.rb | 7 ++++
test/models/restaurant_test.rb | 7 ++++
19 files changed, 182 insertions(+), 8 deletions(-)
create mode 100644 app/models/owner.rb
create mode 100644 app/models/reservation.rb
create mode 100644 app/models/restaurant.rb
create mode 100644 app/views/sessions/sessions.html.erb
create mode 100644 db/migrate/20180124180823_create_reservations.rb
create mode 100644 db/migrate/20180124182405_create_restaurants.rb
create mode 100644 db/migrate/20180124182711_create_owners.rb
create mode 100644 test/fixtures/owners.yml
create mode 100644 test/fixtures/reservations.yml
create mode 100644 test/fixtures/restaurants.yml
create mode 100644 test/models/owner_test.rb
create mode 100644 test/models/reservation_test.rb
create mode 100644 test/models/restaurant_test.rb
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 51088ccf..a7ea9400 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -24,4 +24,5 @@ def ensure_user_reservation
redirect_to root_path
end
end
+
end
diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb
index 7405a63a..d3df5ee0 100644
--- a/app/controllers/reservations_controller.rb
+++ b/app/controllers/reservations_controller.rb
@@ -1,4 +1,6 @@
class ReservationsController < ApplicationController
+ before_action :ensure_logged_in, only: [:create, :edit, :destroy]
+ # before_action :load_restaurant
def index
@reservations = Reservations.all
@@ -22,14 +24,12 @@ def create
@reservaiton.name = params[:reservation][:name]
@reservaiton.date = params[:reservation][:date]
@reservaiton.number_of_people = params[:reservation][:number_of_people]
-
if @resevation.save
- redirect_to resturants_path, notice: 'Resevations have succesfully been booked'
+ redirect_to resturants_path, notice: 'Reservation have succesfully been booked'
else
- render 'resturants'
+ render 'restaurants'
end
end
-
def update
@reservation = Reservation.find(params[:id])
diff --git a/app/models/owner.rb b/app/models/owner.rb
new file mode 100644
index 00000000..d0a72063
--- /dev/null
+++ b/app/models/owner.rb
@@ -0,0 +1,2 @@
+class Owner < ApplicationRecord
+end
diff --git a/app/models/reservation.rb b/app/models/reservation.rb
new file mode 100644
index 00000000..773f0c86
--- /dev/null
+++ b/app/models/reservation.rb
@@ -0,0 +1,2 @@
+class Reservation < ApplicationRecord
+end
diff --git a/app/models/restaurant.rb b/app/models/restaurant.rb
new file mode 100644
index 00000000..ee1243c7
--- /dev/null
+++ b/app/models/restaurant.rb
@@ -0,0 +1,2 @@
+class Restaurant < ApplicationRecord
+end
diff --git a/app/views/reservations/index.html.erb b/app/views/reservations/index.html.erb
index e69de29b..0a923abc 100644
--- a/app/views/reservations/index.html.erb
+++ b/app/views/reservations/index.html.erb
@@ -0,0 +1,10 @@
+<% @reservations.each do |reservation| %>
+
+ <%= reservation.restaurant.name %>
+ <%= reservation.customer.name %>
+ <%= reservation.time %>
+ <%= reservation.restaurant.location %>
+ <%= reservation.size %>
+ <%= reservation.created_at %>
+
+<% end %>
diff --git a/app/views/reservations/new.html.erb b/app/views/reservations/new.html.erb
index e69de29b..a5dd68f7 100644
--- a/app/views/reservations/new.html.erb
+++ b/app/views/reservations/new.html.erb
@@ -0,0 +1,32 @@
+Book a New Reservation
+
+<%= form_for(@reservation) do |f| %>
+
+
+ <%= f.label :time %>
+ <%= f.datetime_select :time %>
+
+
+ <%= f.label :size %>
+ <%= f.number_field :size %>
+
+
+ <%= f.submit %>
+
+<% end %>
+
+<%= form_for(@reservation) do |f| %>
+ <% if @reservation.errors.any? %>
+
+
<%= pluralize(@reservation.errors.count, "error") %> prohibited this product from being saved:
+
+
+ <% @reservation.errors.full_messages.each do |msg| %>
+ - <%= msg %>
+ <% end %>
+
+
+ <% end %>
+<% end %>
+
+<%= link_to 'Back', restaurants_path %>
diff --git a/app/views/sessions/sessions.html.erb b/app/views/sessions/sessions.html.erb
new file mode 100644
index 00000000..e69de29b
diff --git a/config/routes.rb b/config/routes.rb
index d4367ccc..e8e741b7 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,8 +1,8 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
- root 'resturants#index'
- resources :resturants
+ root 'restaurants#index'
+ resources :restaurants
# get 'resturants' => 'resturants#index'
#
@@ -46,7 +46,7 @@
#
get 'sessions/new' => 'sessions#new'
post 'sessions/create' => 'sessions#create'
-
+
end
diff --git a/db/migrate/20180124180823_create_reservations.rb b/db/migrate/20180124180823_create_reservations.rb
new file mode 100644
index 00000000..14083a2a
--- /dev/null
+++ b/db/migrate/20180124180823_create_reservations.rb
@@ -0,0 +1,13 @@
+class CreateReservations < ActiveRecord::Migration[5.0]
+ def change
+ create_table :reservations do |t|
+
+ t.string :user_id
+ t.string :restaurant_id
+ t.datetime :when
+ t.integer :number_of_people
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180124182405_create_restaurants.rb b/db/migrate/20180124182405_create_restaurants.rb
new file mode 100644
index 00000000..109682e4
--- /dev/null
+++ b/db/migrate/20180124182405_create_restaurants.rb
@@ -0,0 +1,16 @@
+class CreateRestaurants < ActiveRecord::Migration[5.0]
+ def change
+ create_table :restaurants do |t|
+
+ t.string :name
+ t.string :address
+ t.integer :capacity
+ t.string :menu
+ t.text :summary
+ t.integer :price
+ t.integer :owner_id
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20180124182711_create_owners.rb b/db/migrate/20180124182711_create_owners.rb
new file mode 100644
index 00000000..010d481c
--- /dev/null
+++ b/db/migrate/20180124182711_create_owners.rb
@@ -0,0 +1,13 @@
+class CreateOwners < ActiveRecord::Migration[5.0]
+ def change
+ create_table :owners do |t|
+
+ t.string :email
+ t.string :password_digest
+ t.string :name
+ t.string :phone
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index dbb29380..3380e96c 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,36 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20180123222244) do
+ActiveRecord::Schema.define(version: 20180124182711) do
+
+ create_table "owners", force: :cascade do |t|
+ t.string "email"
+ t.string "password_digest"
+ t.string "name"
+ t.string "phone"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "reservations", force: :cascade do |t|
+ t.string "user_id"
+ t.string "restaurant_id"
+ t.datetime "when"
+ t.integer "number_of_people"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "restaurants", force: :cascade do |t|
+ t.string "name"
+ t.integer "capacity"
+ t.string "address"
+ t.integer "price"
+ t.text "description"
+ t.integer "owner_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
create_table "users", force: :cascade do |t|
t.string "name"
diff --git a/test/fixtures/owners.yml b/test/fixtures/owners.yml
new file mode 100644
index 00000000..80aed36e
--- /dev/null
+++ b/test/fixtures/owners.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/reservations.yml b/test/fixtures/reservations.yml
new file mode 100644
index 00000000..80aed36e
--- /dev/null
+++ b/test/fixtures/reservations.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/restaurants.yml b/test/fixtures/restaurants.yml
new file mode 100644
index 00000000..80aed36e
--- /dev/null
+++ b/test/fixtures/restaurants.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/models/owner_test.rb b/test/models/owner_test.rb
new file mode 100644
index 00000000..d857cee8
--- /dev/null
+++ b/test/models/owner_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class OwnerTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/reservation_test.rb b/test/models/reservation_test.rb
new file mode 100644
index 00000000..391559fd
--- /dev/null
+++ b/test/models/reservation_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ReservationTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/restaurant_test.rb b/test/models/restaurant_test.rb
new file mode 100644
index 00000000..b45b7417
--- /dev/null
+++ b/test/models/restaurant_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class RestaurantTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
From 707e541bc6760bb2c1ed3e1dc76c01995a6874bb Mon Sep 17 00:00:00 2001
From: "paulcosta2001@gmail.com"
Date: Wed, 24 Jan 2018 13:42:12 -0500
Subject: [PATCH 12/30] restaurant controller, viewform_restaurants,
modelrestaurants migraterestaurants
---
app/controllers/restaurants_controller.rb | 35 +++++++++++
app/models/restaurant.rb | 2 +
...t.html.erb => current_restaurant.html.erb} | 0
...rant.html.erb => form_restaurant.html.erb} | 27 ++++++---
app/views/restaurants/new.html.erb | 60 +++++++++++++++++++
config/routes.rb | 41 +------------
db/migrate/20180123222244_create_users.rb | 2 +-
db/{ => migrate}/schema.rb | 17 +++++-
test/fixtures/restaurants.yml | 11 ++++
test/models/restaurant_test.rb | 7 +++
10 files changed, 153 insertions(+), 49 deletions(-)
create mode 100644 app/models/restaurant.rb
rename app/views/restaurants/{_current_restaurant.html.erb => current_restaurant.html.erb} (100%)
rename app/views/restaurants/{_form_restaurant.html.erb => form_restaurant.html.erb} (82%)
rename db/{ => migrate}/schema.rb (70%)
create mode 100644 test/fixtures/restaurants.yml
create mode 100644 test/models/restaurant_test.rb
diff --git a/app/controllers/restaurants_controller.rb b/app/controllers/restaurants_controller.rb
index 3265ef85..6ce6529e 100644
--- a/app/controllers/restaurants_controller.rb
+++ b/app/controllers/restaurants_controller.rb
@@ -1,2 +1,37 @@
class RestaurantsController < ApplicationController
+
+def index
+end
+
+ def create
+@restaurant = Restaurant.new
+@restaurant.name = params[:restaurant][:name]
+@restaurant.address = params[:restaurant][:address]
+@restaurant.capacity = params[:restaurant][:capacity]
+@restaurant.menu = params[:restaurant][:menu]
+@restaurant.summary = params[:restaurant][:summary]
+@restaurant.price = params[:restaurant][:price]
+@restaurant.owner_id = params[:restaurant][:owner_id]
+
+# @restaurant.open_time = Time.utc(params[:restaurant]["open_time(1i)"].to_i,
+# params[:restaurant]["open_time(2i)"].to_i,
+# params[:restaurant]["open_time(3i)"].to_i,
+#
+#
+# @restaurant.close_time = Time.utc(params[:restaurant]["close_time(1i)"].to_i,
+# params[:restaurant]["close_time(2i)"].to_i,
+# params[:restaurant]["close_time(3i)"].to_i,
+#
+#
+# @restaurant.user_id = current_user.id
+#
+#
+
+ if @restaurant.save
+ redirect_to restaurants_url
+
+ else
+ render :new
+ end
+ end
end
diff --git a/app/models/restaurant.rb b/app/models/restaurant.rb
new file mode 100644
index 00000000..ee1243c7
--- /dev/null
+++ b/app/models/restaurant.rb
@@ -0,0 +1,2 @@
+class Restaurant < ApplicationRecord
+end
diff --git a/app/views/restaurants/_current_restaurant.html.erb b/app/views/restaurants/current_restaurant.html.erb
similarity index 100%
rename from app/views/restaurants/_current_restaurant.html.erb
rename to app/views/restaurants/current_restaurant.html.erb
diff --git a/app/views/restaurants/_form_restaurant.html.erb b/app/views/restaurants/form_restaurant.html.erb
similarity index 82%
rename from app/views/restaurants/_form_restaurant.html.erb
rename to app/views/restaurants/form_restaurant.html.erb
index 80d6abbf..4d5d3038 100644
--- a/app/views/restaurants/_form_restaurant.html.erb
+++ b/app/views/restaurants/form_restaurant.html.erb
@@ -3,24 +3,39 @@
<%= f.label :name %>
<%= f.text_field :name %>
-
- <%= f.label :cuisine %>
- <%= f.text_field :cuisine %>
-
+
<%= f.label :address %>
<%= f.text_field :address%>
+
<%= f.label :capacity %>
<%= f.text_field :capacity%>
+
+
+ <%= f.label :menu %>
+ <%= f.text_field :menu %>
+
+
+
+ <%= f.label :summary %>
+ <%= f.text_field :summary %>
+
+
+
+ <%= f.label :price %>
+ <%= f.text_field :price %>
+
+
<%= f.label :open_time %>
<%= f.time_select :open_time,
:minute_step =>30,
:ampm => true %>
+
<%= f.label :close_time %>
<%= f.time_select :close_time,
@@ -28,10 +43,6 @@
:ampm => true %>
-
- <%= f.label :image_url %>
- <%= f.text_field :image_url%>
-
<%= f.submit %>
diff --git a/app/views/restaurants/new.html.erb b/app/views/restaurants/new.html.erb
index e69de29b..5633a937 100644
--- a/app/views/restaurants/new.html.erb
+++ b/app/views/restaurants/new.html.erb
@@ -0,0 +1,60 @@
+<%= form_for @restaurant do |f|%>
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+
+
+ <%= f.label :address %>
+ <%= f.text_field :address%>
+
+
+
+ <%= f.label :capacity %>
+ <%= f.text_field :capacity%>
+
+
+
+ <%= f.label :menu %>
+ <%= f.text_field :menu %>
+
+
+
+ <%= f.label :summary %>
+ <%= f.text_field :summary %>
+
+
+
+ <%= f.label :price %>
+ <%= f.text_field :price %>
+
+
+
+
+ <%= f.submit %>
+
+ <% if restaurant.errors.any? %>
+
+
<%= pluralize(restaurant.errors.count, "error") %> prohibited this product from being saved:
+
+
+ <% restaurant.errors.full_messages.each do |msg| %>
+ - <%= msg %>
+ <% end %>
+
+
+ <% end %>
+<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 7bd468d8..750f0fda 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,52 +1,15 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
- root 'resturants#index'
- resources :resturants
-
- # get 'resturants' => 'resturants#index'
- #
- # post 'resturants' => 'resturants#create'
- # get 'resturants/new' => 'resturants#new'
- #
- # get 'resturants/:id' => 'resturants#show'
- #
- # get 'resturants/:id/edit' => "resturants#edit"
- # patch 'resturants/:id' => "resturants#update"
- #
- # delete 'resturants/:id' => 'resturants#destroy'
+ root to: 'restaurants#index'
+ resources :restaurants
get 'sessions/new' => 'sessions#new'
post 'sessions/create' => 'sessions#create'
-# User
resources :users
-# Reservations
-
resources :reservations
- # get 'reservations/new' => 'reservations#new'
- # post 'reservations/create' => 'reservations#create'
- #
- # root 'reservations#index'
- #
- # get 'reservations' => 'reservations#index'
- #
- # post 'reservations' => 'reservations#create'
- # get 'reservations/new' => 'reservations#new'
- #
- # get 'reservations/:id' => 'reservations#show'
- #
- # get 'reservations/:id/edit' => "reservations#edit"
- # patch 'reservations/:id' => "reservations#update"
- #
- # delete 'reservations/:id' => 'reservations#destroy'
- #
- #
- # get 'sessions/new' => 'sessions#new'
- # post 'sessions/create' => 'sessions#create'
- #
-
end
diff --git a/db/migrate/20180123222244_create_users.rb b/db/migrate/20180123222244_create_users.rb
index def5e913..30b3d26b 100644
--- a/db/migrate/20180123222244_create_users.rb
+++ b/db/migrate/20180123222244_create_users.rb
@@ -8,6 +8,6 @@ def change
t.string :phone_number
t.timestamps
- end
+ end
end
end
diff --git a/db/schema.rb b/db/migrate/schema.rb
similarity index 70%
rename from db/schema.rb
rename to db/migrate/schema.rb
index dbb29380..ad572fe2 100644
--- a/db/schema.rb
+++ b/db/migrate/schema.rb
@@ -10,7 +10,22 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20180123222244) do
+ActiveRecord::Schema.define(version: 20180124160751) do
+
+ create_table "restaurants", force: :cascade do |t|
+
+ t.string "name"
+ t.integer "capacity"
+ t.string "address"
+ t.string "menu"
+ t.string "summary"
+ t.string "price"
+ t.datetime "open_time"
+ t.datetime "close_time"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "users", force: :cascade do |t|
t.string "name"
diff --git a/test/fixtures/restaurants.yml b/test/fixtures/restaurants.yml
new file mode 100644
index 00000000..80aed36e
--- /dev/null
+++ b/test/fixtures/restaurants.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/models/restaurant_test.rb b/test/models/restaurant_test.rb
new file mode 100644
index 00000000..b45b7417
--- /dev/null
+++ b/test/models/restaurant_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class RestaurantTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
From 49e5206d07486744475d48258f26c7e437638b09 Mon Sep 17 00:00:00 2001
From: "paulcosta2001@gmail.com"
Date: Wed, 24 Jan 2018 14:04:48 -0500
Subject: [PATCH 13/30] rename folder form_restaurants
---
app/controllers/restaurants_controller.rb | 5 +++--
.../restaurants/{form_restaurant.html.erb => index.html.erb} | 0
2 files changed, 3 insertions(+), 2 deletions(-)
rename app/views/restaurants/{form_restaurant.html.erb => index.html.erb} (100%)
diff --git a/app/controllers/restaurants_controller.rb b/app/controllers/restaurants_controller.rb
index 6ce6529e..738545bf 100644
--- a/app/controllers/restaurants_controller.rb
+++ b/app/controllers/restaurants_controller.rb
@@ -1,7 +1,8 @@
class RestaurantsController < ApplicationController
-def index
-end
+ def new
+ @restaurant = Restaurant.new
+ end
def create
@restaurant = Restaurant.new
diff --git a/app/views/restaurants/form_restaurant.html.erb b/app/views/restaurants/index.html.erb
similarity index 100%
rename from app/views/restaurants/form_restaurant.html.erb
rename to app/views/restaurants/index.html.erb
From fed055d443897d0d1d27ab381e014e6ed63ba000 Mon Sep 17 00:00:00 2001
From: vioif
Date: Wed, 24 Jan 2018 14:21:51 -0500
Subject: [PATCH 14/30] resevation page functioning
---
app/views/reservations/new.html.erb | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/app/views/reservations/new.html.erb b/app/views/reservations/new.html.erb
index a5dd68f7..84c128ca 100644
--- a/app/views/reservations/new.html.erb
+++ b/app/views/reservations/new.html.erb
@@ -2,17 +2,26 @@
<%= form_for(@reservation) do |f| %>
-
- <%= f.label :time %>
- <%= f.datetime_select :time %>
-
-
- <%= f.label :size %>
- <%= f.number_field :size %>
-
-
+
+ <%= f.label :user_id %>
+ <%= f.text_field :user_id %>
+
+
+ <%= f.label :restaurant_id %>
+ <%= f.text_field :restaurant_id %>
+
+
+ <%= f.label :when %>
+ <%= f.datetime_field :when %>
+
+
+ <%= f.label :number_of_people %>
+ <%= f.number_field :number_of_people %>
+
+
+
<%= f.submit %>
-
+
<% end %>
<%= form_for(@reservation) do |f| %>
From 225fa8ba3bf49617b9c42ca740ad85c8b814859d Mon Sep 17 00:00:00 2001
From: vioif
Date: Wed, 24 Jan 2018 15:05:56 -0500
Subject: [PATCH 15/30] modified resevation time and now able to rollback
migrations
---
app/views/reservations/new.html.erb | 8 ++++++--
.../20180124180823_create_reservations.rb | 4 ++++
db/migrate/20180124193137_reservation_time.rb | 17 +++++++++++++++++
db/schema.rb | 5 +++--
4 files changed, 30 insertions(+), 4 deletions(-)
create mode 100644 db/migrate/20180124193137_reservation_time.rb
diff --git a/app/views/reservations/new.html.erb b/app/views/reservations/new.html.erb
index 84c128ca..0f720528 100644
--- a/app/views/reservations/new.html.erb
+++ b/app/views/reservations/new.html.erb
@@ -11,8 +11,12 @@
<%= f.text_field :restaurant_id %>
- <%= f.label :when %>
- <%= f.datetime_field :when %>
+ <%= f.label :date %>
+ <%= f.date_field :date %>
+
+
+ <%= f.label :time %>
+ <%= f.time_field :time %>
<%= f.label :number_of_people %>
diff --git a/db/migrate/20180124180823_create_reservations.rb b/db/migrate/20180124180823_create_reservations.rb
index 14083a2a..f87a9139 100644
--- a/db/migrate/20180124180823_create_reservations.rb
+++ b/db/migrate/20180124180823_create_reservations.rb
@@ -2,6 +2,10 @@ class CreateReservations < ActiveRecord::Migration[5.0]
def change
create_table :reservations do |t|
+ # this is the proper way
+ # t.belongs_to :user
+ # t.belongs_to :restaurant
+
t.string :user_id
t.string :restaurant_id
t.datetime :when
diff --git a/db/migrate/20180124193137_reservation_time.rb b/db/migrate/20180124193137_reservation_time.rb
new file mode 100644
index 00000000..e0fa543b
--- /dev/null
+++ b/db/migrate/20180124193137_reservation_time.rb
@@ -0,0 +1,17 @@
+class ReservationTime < ActiveRecord::Migration[5.0]
+ def up
+ change_table :reservations do |t|
+ t.date :date
+ t.integer :time
+ t.remove :when
+ end
+ end
+
+ def down
+ change_table :reservations do |t|
+ t.remove :date
+ t.remove :time
+ t.datetime :when
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 3380e96c..861e1921 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: 20180124182711) do
+ActiveRecord::Schema.define(version: 20180124193137) do
create_table "owners", force: :cascade do |t|
t.string "email"
@@ -24,10 +24,11 @@
create_table "reservations", force: :cascade do |t|
t.string "user_id"
t.string "restaurant_id"
- t.datetime "when"
t.integer "number_of_people"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.date "date"
+ t.integer "time"
end
create_table "restaurants", force: :cascade do |t|
From 2844dfb6dd0e58bacc279c078af32ab6711bd488 Mon Sep 17 00:00:00 2001
From: vioif
Date: Wed, 24 Jan 2018 15:23:45 -0500
Subject: [PATCH 16/30] changed reservations time and date slot
---
app/controllers/restaurants_controller.rb | 36 +++++++++++
...t.html.erb => current_restaurant.html.erb} | 0
...orm_restaurant.html.erb => index.html.erb} | 27 ++++++---
app/views/restaurants/new.html.erb | 60 +++++++++++++++++++
config/routes.rb | 39 +-----------
db/migrate/20180123222244_create_users.rb | 2 +-
...0124191759_add_open_time_to_restaurants.rb | 6 ++
db/migrate/schema.rb | 53 ++++++++++++++++
8 files changed, 176 insertions(+), 47 deletions(-)
rename app/views/restaurants/{_current_restaurant.html.erb => current_restaurant.html.erb} (100%)
rename app/views/restaurants/{_form_restaurant.html.erb => index.html.erb} (82%)
create mode 100644 db/migrate/20180124191759_add_open_time_to_restaurants.rb
create mode 100644 db/migrate/schema.rb
diff --git a/app/controllers/restaurants_controller.rb b/app/controllers/restaurants_controller.rb
index 3265ef85..738545bf 100644
--- a/app/controllers/restaurants_controller.rb
+++ b/app/controllers/restaurants_controller.rb
@@ -1,2 +1,38 @@
class RestaurantsController < ApplicationController
+
+ def new
+ @restaurant = Restaurant.new
+ end
+
+ def create
+@restaurant = Restaurant.new
+@restaurant.name = params[:restaurant][:name]
+@restaurant.address = params[:restaurant][:address]
+@restaurant.capacity = params[:restaurant][:capacity]
+@restaurant.menu = params[:restaurant][:menu]
+@restaurant.summary = params[:restaurant][:summary]
+@restaurant.price = params[:restaurant][:price]
+@restaurant.owner_id = params[:restaurant][:owner_id]
+
+# @restaurant.open_time = Time.utc(params[:restaurant]["open_time(1i)"].to_i,
+# params[:restaurant]["open_time(2i)"].to_i,
+# params[:restaurant]["open_time(3i)"].to_i,
+#
+#
+# @restaurant.close_time = Time.utc(params[:restaurant]["close_time(1i)"].to_i,
+# params[:restaurant]["close_time(2i)"].to_i,
+# params[:restaurant]["close_time(3i)"].to_i,
+#
+#
+# @restaurant.user_id = current_user.id
+#
+#
+
+ if @restaurant.save
+ redirect_to restaurants_url
+
+ else
+ render :new
+ end
+ end
end
diff --git a/app/views/restaurants/_current_restaurant.html.erb b/app/views/restaurants/current_restaurant.html.erb
similarity index 100%
rename from app/views/restaurants/_current_restaurant.html.erb
rename to app/views/restaurants/current_restaurant.html.erb
diff --git a/app/views/restaurants/_form_restaurant.html.erb b/app/views/restaurants/index.html.erb
similarity index 82%
rename from app/views/restaurants/_form_restaurant.html.erb
rename to app/views/restaurants/index.html.erb
index 80d6abbf..4d5d3038 100644
--- a/app/views/restaurants/_form_restaurant.html.erb
+++ b/app/views/restaurants/index.html.erb
@@ -3,24 +3,39 @@
<%= f.label :name %>
<%= f.text_field :name %>
-
- <%= f.label :cuisine %>
- <%= f.text_field :cuisine %>
-
+
<%= f.label :address %>
<%= f.text_field :address%>
+
<%= f.label :capacity %>
<%= f.text_field :capacity%>
+
+
+ <%= f.label :menu %>
+ <%= f.text_field :menu %>
+
+
+
+ <%= f.label :summary %>
+ <%= f.text_field :summary %>
+
+
+
+ <%= f.label :price %>
+ <%= f.text_field :price %>
+
+
<%= f.label :open_time %>
<%= f.time_select :open_time,
:minute_step =>30,
:ampm => true %>
+
<%= f.label :close_time %>
<%= f.time_select :close_time,
@@ -28,10 +43,6 @@
:ampm => true %>
-
- <%= f.label :image_url %>
- <%= f.text_field :image_url%>
-
<%= f.submit %>
diff --git a/app/views/restaurants/new.html.erb b/app/views/restaurants/new.html.erb
index e69de29b..faa53c9b 100644
--- a/app/views/restaurants/new.html.erb
+++ b/app/views/restaurants/new.html.erb
@@ -0,0 +1,60 @@
+<%= form_for @restaurant do |f|%>
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+
+
+ <%= f.label :address %>
+ <%= f.text_field :address%>
+
+
+
+ <%= f.label :capacity %>
+ <%= f.text_field :capacity%>
+
+
+
+ <%= f.label :menu %>
+ <%= f.text_field :menu %>
+
+
+
+ <%= f.label :summary %>
+ <%= f.text_field :summary %>
+
+
+
+ <%= f.label :price %>
+ <%= f.text_field :price %>
+
+
+
+
+ <%= f.submit %>
+
+ <% if @restaurant.errors.any? %>
+
+
<%= pluralize(restaurant.errors.count, "error") %> prohibited this product from being saved:
+
+
+ <% @restaurant.errors.full_messages.each do |msg| %>
+ - <%= msg %>
+ <% end %>
+
+
+ <% end %>
+<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index e8e741b7..efd922d5 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,52 +1,15 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
- root 'restaurants#index'
+ root to: 'restaurants#index'
resources :restaurants
- # get 'resturants' => 'resturants#index'
- #
- # post 'resturants' => 'resturants#create'
- # get 'resturants/new' => 'resturants#new'
- #
- # get 'resturants/:id' => 'resturants#show'
- #
- # get 'resturants/:id/edit' => "resturants#edit"
- # patch 'resturants/:id' => "resturants#update"
- #
- # delete 'resturants/:id' => 'resturants#destroy'
-
get 'sessions/new' => 'sessions#new'
post 'sessions/create' => 'sessions#create'
-# User
resources :users
-# Reservations
-
resources :reservations
- # get 'reservations/new' => 'reservations#new'
- # post 'reservations/create' => 'reservations#create'
- #
- # root 'reservations#index'
- #
- # get 'reservations' => 'reservations#index'
- #
- # post 'reservations' => 'reservations#create'
- # get 'reservations/new' => 'reservations#new'
- #
- # get 'reservations/:id' => 'reservations#show'
- #
- # get 'reservations/:id/edit' => "reservations#edit"
- # patch 'reservations/:id' => "reservations#update"
- #
- # delete 'reservations/:id' => 'reservations#destroy'
- #
- #
- get 'sessions/new' => 'sessions#new'
- post 'sessions/create' => 'sessions#create'
-
-
end
diff --git a/db/migrate/20180123222244_create_users.rb b/db/migrate/20180123222244_create_users.rb
index def5e913..30b3d26b 100644
--- a/db/migrate/20180123222244_create_users.rb
+++ b/db/migrate/20180123222244_create_users.rb
@@ -8,6 +8,6 @@ def change
t.string :phone_number
t.timestamps
- end
+ end
end
end
diff --git a/db/migrate/20180124191759_add_open_time_to_restaurants.rb b/db/migrate/20180124191759_add_open_time_to_restaurants.rb
new file mode 100644
index 00000000..b16a0796
--- /dev/null
+++ b/db/migrate/20180124191759_add_open_time_to_restaurants.rb
@@ -0,0 +1,6 @@
+class AddOpenTimeToRestaurants < ActiveRecord::Migration[5.0]
+ def change
+ add_column :restaurants, :open_time, :integer
+ add_column :restaurants, :close_time, :integer
+ end
+end
diff --git a/db/migrate/schema.rb b/db/migrate/schema.rb
new file mode 100644
index 00000000..3380e96c
--- /dev/null
+++ b/db/migrate/schema.rb
@@ -0,0 +1,53 @@
+# 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.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 20180124182711) do
+
+ create_table "owners", force: :cascade do |t|
+ t.string "email"
+ t.string "password_digest"
+ t.string "name"
+ t.string "phone"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "reservations", force: :cascade do |t|
+ t.string "user_id"
+ t.string "restaurant_id"
+ t.datetime "when"
+ t.integer "number_of_people"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "restaurants", force: :cascade do |t|
+ t.string "name"
+ t.integer "capacity"
+ t.string "address"
+ t.integer "price"
+ t.text "description"
+ t.integer "owner_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "users", force: :cascade do |t|
+ t.string "name"
+ t.string "password_digest"
+ t.string "email"
+ t.string "phone_number"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+end
From 1a460f2539521003b43275ecb712795f479a2e52 Mon Sep 17 00:00:00 2001
From: "paulcosta2001@gmail.com"
Date: Wed, 24 Jan 2018 15:38:22 -0500
Subject: [PATCH 17/30] controller time and index
---
app/controllers/restaurants_controller.rb | 14 ++++----------
app/views/restaurants/index.html.erb | 4 ++--
2 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/app/controllers/restaurants_controller.rb b/app/controllers/restaurants_controller.rb
index 738545bf..72f6e65b 100644
--- a/app/controllers/restaurants_controller.rb
+++ b/app/controllers/restaurants_controller.rb
@@ -13,22 +13,16 @@ def create
@restaurant.summary = params[:restaurant][:summary]
@restaurant.price = params[:restaurant][:price]
@restaurant.owner_id = params[:restaurant][:owner_id]
-
-# @restaurant.open_time = Time.utc(params[:restaurant]["open_time(1i)"].to_i,
-# params[:restaurant]["open_time(2i)"].to_i,
-# params[:restaurant]["open_time(3i)"].to_i,
-#
#
-# @restaurant.close_time = Time.utc(params[:restaurant]["close_time(1i)"].to_i,
-# params[:restaurant]["close_time(2i)"].to_i,
-# params[:restaurant]["close_time(3i)"].to_i,
+# @restaurant.open_time = params[:restaurant]["open_time(1i)"].to_i,
#
+# @restaurant.close_time = params[:restaurant]["close_time(1i)"].to_i,
#
# @restaurant.user_id = current_user.id
#
-#
- if @restaurant.save
+
+ if restaurant.save
redirect_to restaurants_url
else
diff --git a/app/views/restaurants/index.html.erb b/app/views/restaurants/index.html.erb
index 4d5d3038..bbf7274f 100644
--- a/app/views/restaurants/index.html.erb
+++ b/app/views/restaurants/index.html.erb
@@ -46,12 +46,12 @@
<%= f.submit %>
- <% if restaurant.errors.any? %>
+ <% if @restaurant.errors.any? %>
<%= pluralize(restaurant.errors.count, "error") %> prohibited this product from being saved:
- <% restaurant.errors.full_messages.each do |msg| %>
+ <% @restaurant.errors.full_messages.each do |msg| %>
- <%= msg %>
<% end %>
From 560b20cfc417742d48624adc018b51b9fa12f2da Mon Sep 17 00:00:00 2001
From: "paulcosta2001@gmail.com"
Date: Thu, 25 Jan 2018 09:41:52 -0500
Subject: [PATCH 18/30] time update field restaurants controller
---
app/controllers/restaurants_controller.rb | 79 ++++++++++++++++++++---
app/views/restaurants/new.html.erb | 10 ++-
2 files changed, 78 insertions(+), 11 deletions(-)
diff --git a/app/controllers/restaurants_controller.rb b/app/controllers/restaurants_controller.rb
index 72f6e65b..968ccb9c 100644
--- a/app/controllers/restaurants_controller.rb
+++ b/app/controllers/restaurants_controller.rb
@@ -13,20 +13,81 @@ def create
@restaurant.summary = params[:restaurant][:summary]
@restaurant.price = params[:restaurant][:price]
@restaurant.owner_id = params[:restaurant][:owner_id]
-#
-# @restaurant.open_time = params[:restaurant]["open_time(1i)"].to_i,
-#
-# @restaurant.close_time = params[:restaurant]["close_time(1i)"].to_i,
-#
-# @restaurant.user_id = current_user.id
-#
+@restaurant.open_time = params[:restaurant][:open_time]
+@restaurant.close_time = params[:restaurant][:close_time]
- if restaurant.save
- redirect_to restaurants_url
+# @restaurant.user_id = current_user.id
+@restaurant.close_time = Time.utc(params[:restaurant]["close_time(1i)"].to_i,
+ params[:restaurant]["close_time(2i)"].to_i,
+ params[:restaurant]["close_time(3i)"].to_i,
+ params[:restaurant]["close_time(4i)"].to_i,
+ params[:restaurant]["close_time(5i)"].to_i)
+ @restaurant.open_time = Time.utc(params[:restaurant]["open_time(1i)"].to_i,
+ params[:restaurant]["open_time(2i)"].to_i,
+ params[:restaurant]["open_time(3i)"].to_i,
+ params[:restaurant]["open_time(4i)"].to_i,
+ params[:restaurant]["open_time(5i)"].to_i)
+ if @restaurant.save
+ redirect_to restaurants_url notice: 'Restaurant created '
else
render :new
end
end
+
+ def index
+ @restaurant = Restaurant.all
+ end
+
+ def show
+ @restaurant = Restaurant.find(params[:id])
+ end
+
+ def new
+ @restaurant = Restaurant.new
+ end
+
+ def edit
+ @restaurant = Restaurant.find(params[:id])
+ end
+
+ def update
+ @reservation = Reservation.find(params[:id])
+ @restaurant = Restaurant.new
+ @restaurant.name = params[:restaurant][:name]
+ @restaurant.address = params[:restaurant][:address]
+ @restaurant.capacity = params[:restaurant][:capacity]
+ @restaurant.menu = params[:restaurant][:menu]
+ @restaurant.summary = params[:restaurant][:summary]
+ @restaurant.price = params[:restaurant][:price]
+ @restaurant.owner_id = params[:restaurant][:owner_id]
+
+ @restaurant.open_time = params[:restaurant][:open_time]
+ @restaurant.close_time = params[:restaurant][:close_time]
+
+ # @restaurant.user_id = current_user.id
+ @restaurant.close_time = Time.utc(params[:restaurant]["close_time(1i)"].to_i,
+ params[:restaurant]["close_time(2i)"].to_i,
+ params[:restaurant]["close_time(3i)"].to_i,
+ params[:restaurant]["close_time(4i)"].to_i,
+ params[:restaurant]["close_time(5i)"].to_i)
+ @restaurant.open_time = Time.utc(params[:restaurant]["open_time(1i)"].to_i,
+ params[:restaurant]["open_time(2i)"].to_i,
+ params[:restaurant]["open_time(3i)"].to_i,
+ params[:restaurant]["open_time(4i)"].to_i,
+ params[:restaurant]["open_time(5i)"].to_i)
+ if @restaurant.save
+ redirect_to resturants_url, notice: 'Restaurant updated'
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @restaurant = Restaurant.find(params[:id])
+ @restaurant.destory
+ redirect_to restaurants_url
+ end
+
end
diff --git a/app/views/restaurants/new.html.erb b/app/views/restaurants/new.html.erb
index faa53c9b..56e7170c 100644
--- a/app/views/restaurants/new.html.erb
+++ b/app/views/restaurants/new.html.erb
@@ -1,4 +1,8 @@
+Create New Restaurant
+
+
<%= form_for @restaurant do |f|%>
+
<%= f.label :name %>
<%= f.text_field :name %>
@@ -28,7 +32,9 @@
<%= f.label :price %>
<%= f.text_field :price %>
-
+
<%= f.submit %>
From 8fb4457d53c90cc87e526380970e9dbaf07a7662 Mon Sep 17 00:00:00 2001
From: "paulcosta2001@gmail.com"
Date: Thu, 25 Jan 2018 11:07:56 -0500
Subject: [PATCH 19/30] working new restaurants page+save+redirect index
---
app/controllers/restaurants_controller.rb | 45 +++++++-------
app/views/restaurants/index.html.erb | 61 +------------------
app/views/restaurants/new.html.erb | 2 +-
.../20180124182405_create_restaurants.rb | 4 +-
{lib => log/lib}/assets/.keep | 0
{lib => log/lib}/tasks/.keep | 0
6 files changed, 27 insertions(+), 85 deletions(-)
rename {lib => log/lib}/assets/.keep (100%)
rename {lib => log/lib}/tasks/.keep (100%)
diff --git a/app/controllers/restaurants_controller.rb b/app/controllers/restaurants_controller.rb
index 968ccb9c..0e0b9d22 100644
--- a/app/controllers/restaurants_controller.rb
+++ b/app/controllers/restaurants_controller.rb
@@ -1,5 +1,9 @@
class RestaurantsController < ApplicationController
+ def index
+ @restaurants = Restaurant.all
+ end
+
def new
@restaurant = Restaurant.new
end
@@ -18,42 +22,38 @@ def create
@restaurant.close_time = params[:restaurant][:close_time]
# @restaurant.user_id = current_user.id
-@restaurant.close_time = Time.utc(params[:restaurant]["close_time(1i)"].to_i,
- params[:restaurant]["close_time(2i)"].to_i,
- params[:restaurant]["close_time(3i)"].to_i,
- params[:restaurant]["close_time(4i)"].to_i,
- params[:restaurant]["close_time(5i)"].to_i)
- @restaurant.open_time = Time.utc(params[:restaurant]["open_time(1i)"].to_i,
- params[:restaurant]["open_time(2i)"].to_i,
- params[:restaurant]["open_time(3i)"].to_i,
- params[:restaurant]["open_time(4i)"].to_i,
- params[:restaurant]["open_time(5i)"].to_i)
+# @restaurant.close_time = Time.utc(params[:restaurant]["close_time(1i)"].to_i,
+# params[:restaurant]["close_time(2i)"].to_i,
+# params[:restaurant]["close_time(3i)"].to_i,
+# params[:restaurant]["close_time(4i)"].to_i,
+# params[:restaurant]["close_time(5i)"].to_i)
+# @restaurant.open_time = Time.utc(params[:restaurant]["open_time(1i)"].to_i,
+# params[:restaurant]["open_time(2i)"].to_i,
+# params[:restaurant]["open_time(3i)"].to_i,
+# params[:restaurant]["open_time(4i)"].to_i,
+# params[:restaurant]["open_time(5i)"].to_i)
if @restaurant.save
- redirect_to restaurants_url notice: 'Restaurant created '
+ redirect_to restaurants_path notice: 'Restaurant created '
else
render :new
end
end
- def index
- @restaurant = Restaurant.all
- end
+
def show
- @restaurant = Restaurant.find(params[:id])
+ @restaurant = Restaurant
end
- def new
- @restaurant = Restaurant.new
- end
+
def edit
@restaurant = Restaurant.find(params[:id])
end
def update
- @reservation = Reservation.find(params[:id])
+ @restaurant = Restaurant.find(params[:id])
@restaurant = Restaurant.new
@restaurant.name = params[:restaurant][:name]
@restaurant.address = params[:restaurant][:address]
@@ -78,16 +78,15 @@ def update
params[:restaurant]["open_time(4i)"].to_i,
params[:restaurant]["open_time(5i)"].to_i)
if @restaurant.save
- redirect_to resturants_url, notice: 'Restaurant updated'
+ redirect_to restaurants_path, notice: 'Restaurant updated'
else
render :edit
end
end
def destroy
- @restaurant = Restaurant.find(params[:id])
- @restaurant.destory
- redirect_to restaurants_url
+ @restaurant.destroy
+ redirect_to restaurants_path
end
end
diff --git a/app/views/restaurants/index.html.erb b/app/views/restaurants/index.html.erb
index bbf7274f..67abb65a 100644
--- a/app/views/restaurants/index.html.erb
+++ b/app/views/restaurants/index.html.erb
@@ -1,60 +1 @@
-<%= form_for @restaurant do |f|%>
-
- <%= f.label :name %>
- <%= f.text_field :name %>
-
-
-
- <%= f.label :address %>
- <%= f.text_field :address%>
-
-
-
- <%= f.label :capacity %>
- <%= f.text_field :capacity%>
-
-
-
- <%= f.label :menu %>
- <%= f.text_field :menu %>
-
-
-
- <%= f.label :summary %>
- <%= f.text_field :summary %>
-
-
-
- <%= f.label :price %>
- <%= f.text_field :price %>
-
-
-
- <%= f.label :open_time %>
- <%= f.time_select :open_time,
- :minute_step =>30,
- :ampm => true %>
-
-
-
- <%= f.label :close_time %>
- <%= f.time_select :close_time,
- :minute_step =>30,
- :ampm => true %>
-
-
-
- <%= f.submit %>
-
- <% if @restaurant.errors.any? %>
-
-
<%= pluralize(restaurant.errors.count, "error") %> prohibited this product from being saved:
-
-
- <% @restaurant.errors.full_messages.each do |msg| %>
- - <%= msg %>
- <% end %>
-
-
- <% end %>
-<% end %>
+index Restaurant
diff --git a/app/views/restaurants/new.html.erb b/app/views/restaurants/new.html.erb
index 56e7170c..97f58bd9 100644
--- a/app/views/restaurants/new.html.erb
+++ b/app/views/restaurants/new.html.erb
@@ -52,7 +52,7 @@
<%= f.submit %>
- <% if @restaurant.errors.any? %>
+ <% if @r.errors.any? %>
<%= pluralize(restaurant.errors.count, "error") %> prohibited this product from being saved:
diff --git a/db/migrate/20180124182405_create_restaurants.rb b/db/migrate/20180124182405_create_restaurants.rb
index 109682e4..9765b83f 100644
--- a/db/migrate/20180124182405_create_restaurants.rb
+++ b/db/migrate/20180124182405_create_restaurants.rb
@@ -8,7 +8,9 @@ def change
t.string :menu
t.text :summary
t.integer :price
- t.integer :owner_id
+ # t.integer :owner_id
+ # t.integer :open_time
+ # t.integer :close_time
t.timestamps
end
diff --git a/lib/assets/.keep b/log/lib/assets/.keep
similarity index 100%
rename from lib/assets/.keep
rename to log/lib/assets/.keep
diff --git a/lib/tasks/.keep b/log/lib/tasks/.keep
similarity index 100%
rename from lib/tasks/.keep
rename to log/lib/tasks/.keep
From ec0c91719b81da6e5895a776fc9061a04901502b Mon Sep 17 00:00:00 2001
From: vioif
Date: Thu, 25 Jan 2018 11:22:25 -0500
Subject: [PATCH 20/30] added users index and fixed up resevationd controller
removed S in reservations index
---
app/controllers/reservations_controller.rb | 2 +-
app/controllers/users_controller.rb | 11 ++++-
app/views/reservations/new.html.erb | 10 +++-
.../restaurants/_form_restaurant.html.erb | 49 +++++++++++++++++++
app/views/users/edit_username.html.erb | 16 ++++++
app/views/users/index.html.erb | 2 +
6 files changed, 86 insertions(+), 4 deletions(-)
create mode 100644 app/views/restaurants/_form_restaurant.html.erb
create mode 100644 app/views/users/index.html.erb
diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb
index d3df5ee0..201e47d8 100644
--- a/app/controllers/reservations_controller.rb
+++ b/app/controllers/reservations_controller.rb
@@ -3,7 +3,7 @@ class ReservationsController < ApplicationController
# before_action :load_restaurant
def index
- @reservations = Reservations.all
+ @reservations = Reservation.all
end
def show
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 7f488718..f5daf005 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,5 +1,8 @@
class UsersController < ApplicationController
+ def index
+ end
+
def new
@user = User.new
end
@@ -16,9 +19,15 @@ def create
p @user
if @user.save
- redirect_to users_url
+ redirect_to users_path
else
render :new
end
end
+
+ def show
+ @user = User.find(params[:id])
+ end
+
+
end
diff --git a/app/views/reservations/new.html.erb b/app/views/reservations/new.html.erb
index 0f720528..c73d16f1 100644
--- a/app/views/reservations/new.html.erb
+++ b/app/views/reservations/new.html.erb
@@ -10,10 +10,16 @@
<%= f.label :restaurant_id %>
<%= f.text_field :restaurant_id %>
-
+
+
+
+ <%= f.label :time %>
+ <%= f.date_field :time %>
+
<%= f.label :time %>
<%= f.time_field :time %>
diff --git a/app/views/restaurants/_form_restaurant.html.erb b/app/views/restaurants/_form_restaurant.html.erb
new file mode 100644
index 00000000..ba30ef16
--- /dev/null
+++ b/app/views/restaurants/_form_restaurant.html.erb
@@ -0,0 +1,49 @@
+<%= form_for @restaurant do |f|%>
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+
+ <%= f.label :cuisine %>
+ <%= f.text_field :cuisine %>
+
+
+ <%= f.label :address %>
+ <%= f.text_field :address%>
+
+
+ <%= f.label :capacity %>
+ <%= f.text_field :capacity%>
+
+
+ <%= f.label :open_time %>
+ <%= f.time_select :open_time,
+ :minute_step =>30,
+ :ampm => true %>
+
+
+ <%= f.label :close_time %>
+ <%= f.time_select :close_time,
+ :minute_step =>30,
+ :ampm => true %>
+
+
+
+ <%= f.label :image_url %>
+ <%= f.text_field :image_url%>
+
+
+ <%= f.submit %>
+
+ <% if restaurant.errors.any? %>
+
+
<%= pluralize(restaurant.errors.count, "error") %> prohibited this product from being saved:
+
+
+ <% restaurant.errors.full_messages.each do |msg| %>
+ - <%= msg %>
+ <% end %>
+
+
+ <% end %>
+<% end %>
diff --git a/app/views/users/edit_username.html.erb b/app/views/users/edit_username.html.erb
index e69de29b..4a4e9cbf 100644
--- a/app/views/users/edit_username.html.erb
+++ b/app/views/users/edit_username.html.erb
@@ -0,0 +1,16 @@
+
+
+
+ Edit Account Settings
+
+
+
+ Edit Settings
+
+ <%= render 'form' %>
+
+ <%= link_to 'cancel', user_path %>
+
+
+
+
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
new file mode 100644
index 00000000..a3018db5
--- /dev/null
+++ b/app/views/users/index.html.erb
@@ -0,0 +1,2 @@
+ Welcome
+Let's find a table.
From 5a25c0a416b164e9480096ad4f3996ffff19ebc5 Mon Sep 17 00:00:00 2001
From: "paulcosta2001@gmail.com"
Date: Thu, 25 Jan 2018 12:00:21 -0500
Subject: [PATCH 21/30] r updated on new.html restaurant
---
app/views/restaurants/new.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/restaurants/new.html.erb b/app/views/restaurants/new.html.erb
index 97f58bd9..56e7170c 100644
--- a/app/views/restaurants/new.html.erb
+++ b/app/views/restaurants/new.html.erb
@@ -52,7 +52,7 @@
<%= f.submit %>
- <% if @r.errors.any? %>
+ <% if @restaurant.errors.any? %>
<%= pluralize(restaurant.errors.count, "error") %> prohibited this product from being saved:
From 5bb3cf43b1f43028ebe7706ed479a35352812555 Mon Sep 17 00:00:00 2001
From: "paulcosta2001@gmail.com"
Date: Thu, 25 Jan 2018 12:46:39 -0500
Subject: [PATCH 22/30] working render index.of db restaurants
---
app/views/restaurants/index.html.erb | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/app/views/restaurants/index.html.erb b/app/views/restaurants/index.html.erb
index 67abb65a..0d5a9f57 100644
--- a/app/views/restaurants/index.html.erb
+++ b/app/views/restaurants/index.html.erb
@@ -1 +1,22 @@
-index Restaurant
+
+Restaurants
+ <%= link_to "See Reservations" %> |
+ <%= link_to("New Restaurant", new_restaurant_path)%>
+ <%= link_to("Back", restaurants_path) %>
+
+
+ <% @restaurants.each do |restaurant| %>
+
+ <%= restaurant.name %>
+ <%= restaurant.address %>
+ <%= restaurant.capacity %>
+ <%= restaurant.menu %>
+ <%= restaurant.summary %>
+ <%= restaurant.price %>
+<%= restaurant.owner_id %>
+<%= restaurant.open_time %>
+<%= restaurant.close_time %>
+
+
+
+ <% end %>
From 2f4b9b6843dd58bd327a975a9bc8621c0276020b Mon Sep 17 00:00:00 2001
From: vioif
Date: Thu, 25 Jan 2018 14:56:00 -0500
Subject: [PATCH 23/30] users now directed to index page and sessions contorl
is still not functioning
---
app/controllers/application_controller.rb | 2 +-
app/controllers/sessions_controller.rb | 4 ++--
app/controllers/users_controller.rb | 2 +-
app/views/users/index.html.erb | 4 +++-
4 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index a7ea9400..10b7c750 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -14,7 +14,7 @@ def current_user
def ensure_logged_in
if !session[:user_id]
flash[:alert] = ["You need to be logged in to do that!"]
- redirect_to new_session_url
+ redirect_to sessions_new_path
end
end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index de6b71c5..d8a4924c 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -7,7 +7,7 @@ def create
user = User.find_by(email: params [:email])
if user && user.authenticate(params [:password])
session[:user_id] = user.id
- redirect_to user_url, notice: "Logged in!"
+ redirect_to new_sessions_path, notice: "Logged in!"
else
flash[:notice] = "Invalid email or password"
render "new"
@@ -16,6 +16,6 @@ def create
def destory
session[:user_id] = nil
- redirect_to user_url, notice: "Logged out!"
+ redirect_to new_sessions_path, notice: "Logged out!"
end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index f5daf005..0e33df84 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -19,7 +19,7 @@ def create
p @user
if @user.save
- redirect_to users_path
+ redirect_to restaurants_path
else
render :new
end
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
index a3018db5..3a3c2df3 100644
--- a/app/views/users/index.html.erb
+++ b/app/views/users/index.html.erb
@@ -1,2 +1,4 @@
- Welcome
+ Welcome to OpenTable
Let's find a table.
+
+ <%= redirect_to restaurants_path notice: 'user created ' %>
From f1d8ca29e4b26d0cd7e8eb366e905821b4f1a658 Mon Sep 17 00:00:00 2001
From: vioif
Date: Thu, 25 Jan 2018 16:10:33 -0500
Subject: [PATCH 24/30] fixed sessions controller and sessions view working
---
app/controllers/sessions_controller.rb | 5 +++--
app/controllers/users_controller.rb | 5 -----
app/views/restaurants/index.html.erb | 2 ++
app/views/sessions/new.html.erb | 12 ++++++------
4 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index d8a4924c..3128461d 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -4,8 +4,9 @@ def new
end
def create
- user = User.find_by(email: params [:email])
- if user && user.authenticate(params [:password])
+ user = User.find_by(email: params[:email])
+
+ if user && user.authenticate(params[:password])
session[:user_id] = user.id
redirect_to new_sessions_path, notice: "Logged in!"
else
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 0e33df84..956a1e34 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -15,9 +15,6 @@ def create
@user.password_confirmation = params[:user][:password_confirmation]
@user.phone_number = params[:user][:phone_number]
- puts "********"
- p @user
-
if @user.save
redirect_to restaurants_path
else
@@ -28,6 +25,4 @@ def create
def show
@user = User.find(params[:id])
end
-
-
end
diff --git a/app/views/restaurants/index.html.erb b/app/views/restaurants/index.html.erb
index 0d5a9f57..abcb3493 100644
--- a/app/views/restaurants/index.html.erb
+++ b/app/views/restaurants/index.html.erb
@@ -3,6 +3,8 @@
<%= link_to "See Reservations" %> |
<%= link_to("New Restaurant", new_restaurant_path)%>
<%= link_to("Back", restaurants_path) %>
+ <%= link_to("Log in", sessions_new_path) %>
+ <%= link_to("Create New User", new_user_path) %>
<% @restaurants.each do |restaurant| %>
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
index f36c98da..c9571af4 100644
--- a/app/views/sessions/new.html.erb
+++ b/app/views/sessions/new.html.erb
@@ -1,13 +1,13 @@
Log in
- <%= form_tag 'sessions_path' do %>
-
+ <%= form_tag 'sessions_new_path' do %>
+
<%= label_tag :email %>
<%= text_field_tag :email, params[:email] %>
-
-
+
+
<%= label_tag :password %>
<%= password_field_tag :password %>
-
- <%= submit_tag "Log in" %>
+
+ <%= submit_tag "Log in" %>
<% end %>
From 98ffda621684485875417d6a1c2d380d858ae911 Mon Sep 17 00:00:00 2001
From: vioif
Date: Thu, 25 Jan 2018 16:14:37 -0500
Subject: [PATCH 25/30] sessions controller functioning now when logged in
---
app/controllers/sessions_controller.rb | 4 ++--
app/views/sessions/new.html.erb | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 3128461d..f2a595fa 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -8,7 +8,7 @@ def create
if user && user.authenticate(params[:password])
session[:user_id] = user.id
- redirect_to new_sessions_path, notice: "Logged in!"
+ redirect_to restaurants_path, notice: "Logged in!"
else
flash[:notice] = "Invalid email or password"
render "new"
@@ -17,6 +17,6 @@ def create
def destory
session[:user_id] = nil
- redirect_to new_sessions_path, notice: "Logged out!"
+ redirect_to restaurants_path, notice: "Logged out!"
end
end
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
index c9571af4..c3f69be2 100644
--- a/app/views/sessions/new.html.erb
+++ b/app/views/sessions/new.html.erb
@@ -1,6 +1,6 @@
Log in
- <%= form_tag 'sessions_new_path' do %>
+ <%= form_tag sessions_create_path do %>
<%= label_tag :email %>
<%= text_field_tag :email, params[:email] %>
From 5c59f1c2dd6c3929090c16b1d984a0f37e77a7e4 Mon Sep 17 00:00:00 2001
From: vioif
Date: Thu, 25 Jan 2018 16:48:33 -0500
Subject: [PATCH 26/30] edited reservation page number field and time field
---
app/views/reservations/new.html.erb | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/app/views/reservations/new.html.erb b/app/views/reservations/new.html.erb
index c73d16f1..2c822e7e 100644
--- a/app/views/reservations/new.html.erb
+++ b/app/views/reservations/new.html.erb
@@ -10,23 +10,19 @@
<%= f.label :restaurant_id %>
<%= f.text_field :restaurant_id %>
-
-
+
- <%= f.label :time %>
- <%= f.date_field :time %>
+ <%= f.label :date %>
+ <%= f.date_field :date %>
<%= f.label :time %>
- <%= f.time_field :time %>
+ <%= f.time_select :time, :ampm => true, :minute_step => 30 %>
<%= f.label :number_of_people %>
- <%= f.number_field :number_of_people %>
+ <%= f.number_field :number_of_people, { min: '1', max: '15'} %>
From 7c5c7a49dab1eba2db0ac1c7d6404c1fcf788f27 Mon Sep 17 00:00:00 2001
From: "paulcosta2001@gmail.com"
Date: Thu, 25 Jan 2018 16:55:01 -0500
Subject: [PATCH 27/30] links on restaurant name to reservations new path
---
app/views/restaurants/index.html.erb | 3 +--
config/routes.rb | 8 +++++---
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/app/views/restaurants/index.html.erb b/app/views/restaurants/index.html.erb
index abcb3493..d084a58d 100644
--- a/app/views/restaurants/index.html.erb
+++ b/app/views/restaurants/index.html.erb
@@ -9,7 +9,7 @@
<% @restaurants.each do |restaurant| %>
- <%= restaurant.name %>
+ <%= link_to(restaurant.name, new_restaurant_reservation_path(restaurant.id)) %>
<%= restaurant.address %>
<%= restaurant.capacity %>
<%= restaurant.menu %>
@@ -19,6 +19,5 @@
<%= restaurant.open_time %>
<%= restaurant.close_time %>
-
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index efd922d5..f0c8d509 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,14 +2,16 @@
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: 'restaurants#index'
- resources :restaurants
-
+ resources :restaurants do
+ resources :reservations
+end
get 'sessions/new' => 'sessions#new'
post 'sessions/create' => 'sessions#create'
resources :users
- resources :reservations
+
+
end
From 2d6174ec408a3839260f24408a022c0c62361ecb Mon Sep 17 00:00:00 2001
From: vioif
Date: Thu, 25 Jan 2018 17:13:23 -0500
Subject: [PATCH 28/30] deleted files
---
test/fixtures/reservation_time_slots.yml | 11 +++++++++++
test/models/reservation_time_slot_test.rb | 7 +++++++
2 files changed, 18 insertions(+)
create mode 100644 test/fixtures/reservation_time_slots.yml
create mode 100644 test/models/reservation_time_slot_test.rb
diff --git a/test/fixtures/reservation_time_slots.yml b/test/fixtures/reservation_time_slots.yml
new file mode 100644
index 00000000..80aed36e
--- /dev/null
+++ b/test/fixtures/reservation_time_slots.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/models/reservation_time_slot_test.rb b/test/models/reservation_time_slot_test.rb
new file mode 100644
index 00000000..4d47e80c
--- /dev/null
+++ b/test/models/reservation_time_slot_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class ReservationTimeSlotTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
From bdbef3020a2c0e46c07e67511517ad2498b7abfc Mon Sep 17 00:00:00 2001
From: vioif
Date: Thu, 25 Jan 2018 18:10:35 -0500
Subject: [PATCH 29/30] reservations now link to restaurant page
---
app/controllers/reservations_controller.rb | 28 +++++++++++-----------
app/views/restaurants/index.html.erb | 6 ++---
config/routes.rb | 1 +
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb
index 201e47d8..9548ae59 100644
--- a/app/controllers/reservations_controller.rb
+++ b/app/controllers/reservations_controller.rb
@@ -7,7 +7,7 @@ def index
end
def show
- @resevation = Reservation.find(params[:id])
+ @reservation = Reservation.find(params[:id])
end
def new
@@ -15,17 +15,17 @@ def new
end
def edit
- @resevation = Reservation.find(params[:id])
+ @reservation = Reservation.find(params[:id])
end
def create
- @reservaiton = Reservation.new
+ @reservation = Reservation.new
- @reservaiton.name = params[:reservation][:name]
- @reservaiton.date = params[:reservation][:date]
- @reservaiton.number_of_people = params[:reservation][:number_of_people]
- if @resevation.save
- redirect_to resturants_path, notice: 'Reservation have succesfully been booked'
+ @reservation.user_id = params[:reservation][:user_id]
+ @reservation.date = params[:reservation][:date]
+ @reservation.number_of_people = params[:reservation][:number_of_people]
+ if @reservation.save
+ redirect_to restaurants_path, notice: 'Reservation have succesfully been booked'
else
render 'restaurants'
end
@@ -33,11 +33,11 @@ def create
def update
@reservation = Reservation.find(params[:id])
- @reservaiton.name = params[:reservation][:name]
- @reservaiton.date = params[:reservation][:date]
- @reservaiton.number_of_people = params[:reservation][:number_of_people]
+ @reservatiton.name = params[:reservation][:name]
+ @reservation.date = params[:reservation][:date]
+ @reservation.number_of_people = params[:reservation][:number_of_people]
- if @resevation.save
+ if @reservation.save
redirect_to resturants_path, notice: 'Resevations have succesfully been updated '
else
render :edit
@@ -45,8 +45,8 @@ def update
end
def destroy
- @reservaiton = Reservation.find(params[:id])
- @reservaiton.destory
+ @reservation = Reservation.find(params[:id])
+ @reservation.destory
redirect_to "/resturants"
end
end
diff --git a/app/views/restaurants/index.html.erb b/app/views/restaurants/index.html.erb
index d084a58d..d395f336 100644
--- a/app/views/restaurants/index.html.erb
+++ b/app/views/restaurants/index.html.erb
@@ -1,12 +1,12 @@
Restaurants
- <%= link_to "See Reservations" %> |
- <%= link_to("New Restaurant", new_restaurant_path)%>
- <%= link_to("Back", restaurants_path) %>
+ <%= link_to("New Restaurant", new_restaurant_path) %>
+ <%= link_to("Back", restaurants_path) %>
<%= link_to("Log in", sessions_new_path) %>
<%= link_to("Create New User", new_user_path) %>
+
<% @restaurants.each do |restaurant| %>
<%= link_to(restaurant.name, new_restaurant_reservation_path(restaurant.id)) %>
diff --git a/config/routes.rb b/config/routes.rb
index f0c8d509..e754dda5 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,6 +2,7 @@
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: 'restaurants#index'
+ resources :reservations
resources :restaurants do
resources :reservations
end
From 8fddd3375a56d0dc3c0fd6d0091c84117a024331 Mon Sep 17 00:00:00 2001
From: vioif
Date: Thu, 25 Jan 2018 19:03:35 -0500
Subject: [PATCH 30/30] reservations now link to individual restaurants
---
app/controllers/reservations_controller.rb | 1 +
app/views/reservations/index.html.erb | 3 ++-
app/views/reservations/new.html.erb | 1 +
app/views/restaurants/_restaurant.html.erb | 12 ++++++++++++
app/views/restaurants/current_restaurant.html.erb | 0
app/views/restaurants/index.html.erb | 14 +++-----------
6 files changed, 19 insertions(+), 12 deletions(-)
create mode 100644 app/views/restaurants/_restaurant.html.erb
delete mode 100644 app/views/restaurants/current_restaurant.html.erb
diff --git a/app/controllers/reservations_controller.rb b/app/controllers/reservations_controller.rb
index 9548ae59..d95f6690 100644
--- a/app/controllers/reservations_controller.rb
+++ b/app/controllers/reservations_controller.rb
@@ -11,6 +11,7 @@ def show
end
def new
+ @restaurant = Restaurant.find(params[:restaurant_id])
@reservation = Reservation.new
end
diff --git a/app/views/reservations/index.html.erb b/app/views/reservations/index.html.erb
index 0a923abc..efa55180 100644
--- a/app/views/reservations/index.html.erb
+++ b/app/views/reservations/index.html.erb
@@ -1,5 +1,6 @@
<% @reservations.each do |reservation| %>
-
+
+
<%= %>
<%= reservation.restaurant.name %>
<%= reservation.customer.name %>
<%= reservation.time %>
diff --git a/app/views/reservations/new.html.erb b/app/views/reservations/new.html.erb
index 2c822e7e..36660996 100644
--- a/app/views/reservations/new.html.erb
+++ b/app/views/reservations/new.html.erb
@@ -1,4 +1,5 @@
Book a New Reservation
+ <%= render @restaurant%>
<%= form_for(@reservation) do |f| %>
diff --git a/app/views/restaurants/_restaurant.html.erb b/app/views/restaurants/_restaurant.html.erb
new file mode 100644
index 00000000..a1da5996
--- /dev/null
+++ b/app/views/restaurants/_restaurant.html.erb
@@ -0,0 +1,12 @@
+
+<%= link_to(restaurant.name, new_restaurant_reservation_path(restaurant.id)) %>
+ <%= restaurant.address %>
+ <%= restaurant.capacity %>
+ <%= restaurant.menu %>
+ <%= restaurant.summary %>
+<%= restaurant.price %>
+<%= restaurant.owner_id %>
+<%= restaurant.open_time %>
+<%= restaurant.close_time %>
+
+
diff --git a/app/views/restaurants/current_restaurant.html.erb b/app/views/restaurants/current_restaurant.html.erb
deleted file mode 100644
index e69de29b..00000000
diff --git a/app/views/restaurants/index.html.erb b/app/views/restaurants/index.html.erb
index d395f336..e1e2fff5 100644
--- a/app/views/restaurants/index.html.erb
+++ b/app/views/restaurants/index.html.erb
@@ -8,16 +8,8 @@
<% @restaurants.each do |restaurant| %>
-
- <%= link_to(restaurant.name, new_restaurant_reservation_path(restaurant.id)) %>
- <%= restaurant.address %>
- <%= restaurant.capacity %>
- <%= restaurant.menu %>
- <%= restaurant.summary %>
- <%= restaurant.price %>
-<%= restaurant.owner_id %>
-<%= restaurant.open_time %>
-<%= restaurant.close_time %>
-
+
+
+ <%= render partial: "restaurant", locals: { restaurant: restaurant } %>
<% end %>