Skip to content

Commit

Permalink
Merge branch 'dev' into final-touches
Browse files Browse the repository at this point in the history
  • Loading branch information
omarsalem7 committed Jun 24, 2022
2 parents aaa3da6 + 080cc46 commit d5a81b5
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.1.1'
ruby '3.0.2'

gem 'devise'
gem 'devise-jwt'
Expand Down Expand Up @@ -37,6 +37,8 @@ gem 'tzinfo-data'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false

gem 'active_model_serializers'

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

Expand Down
18 changes: 12 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ GEM
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
active_model_serializers (0.10.13)
actionpack (>= 4.1, < 7.1)
activemodel (>= 4.1, < 7.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (7.0.3)
activesupport (= 7.0.3)
globalid (>= 0.3.6)
Expand Down Expand Up @@ -73,6 +78,8 @@ GEM
bootsnap (1.12.0)
msgpack (~> 1.2)
builder (3.2.4)
case_transform (0.2)
activesupport
capybara (3.37.1)
addressable
matrix
Expand Down Expand Up @@ -126,7 +133,7 @@ GEM
fast_jsonapi (1.5)
activesupport (>= 4.2)
ffi (1.15.5)
ffi (1.15.5-x64-mingw-ucrt)
ffi (1.15.5-x64-unknown)
globalid (1.0.0)
activesupport (>= 5.0)
i18n (1.10.0)
Expand All @@ -136,6 +143,7 @@ GEM
reline (>= 0.3.0)
json-schema (2.8.1)
addressable (>= 2.4)
jsonapi-renderer (0.2.2)
jwt (2.4.1)
loofah (2.18.0)
crass (~> 1.0.2)
Expand Down Expand Up @@ -163,8 +171,6 @@ GEM
net-protocol
timeout
nio4r (2.5.8)
nokogiri (1.13.6-x64-mingw-ucrt)
racc (~> 1.4)
nokogiri (1.13.6-x64-unknown)
racc (~> 1.4)
nokogiri (1.13.6-x86_64-darwin)
Expand All @@ -176,7 +182,6 @@ GEM
parser (3.1.2.0)
ast (~> 2.4.1)
pg (1.3.5)
pg (1.3.5-x64-mingw-ucrt)
pg (1.3.5-x64-unknown)
public_suffix (4.0.7)
puma (5.6.4)
Expand Down Expand Up @@ -296,12 +301,13 @@ GEM
zeitwerk (2.5.4)

PLATFORMS
x64-mingw-ucrt
x64-unknown
x64-unknown
x86_64-darwin-19
x86_64-linux

DEPENDENCIES
active_model_serializers
bootsnap
capybara
database_cleaner
Expand All @@ -324,7 +330,7 @@ DEPENDENCIES
tzinfo-data

RUBY VERSION
ruby 3.1.1p18
ruby 3.0.2p107

BUNDLED WITH
2.3.14
5 changes: 3 additions & 2 deletions app/controllers/api/reservations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class Api::ReservationsController < ApplicationController
before_action :authenticate_user!
def index
reservations = Reservation.all
render json: reservations
reservations = Reservation.where(user_id: current_user)
render json: reservations, status: 200
end

def create
Expand Down
5 changes: 5 additions & 0 deletions app/serializers/reservation_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ReservationSerializer < ActiveModel::Serializer
attributes :id, :city, :date, :user_id, :course_id

has_one :user
end
9 changes: 4 additions & 5 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ development:
# username: mymac
#####################
# Omar configuration
username: postgres
password: 1234
# username: postgres
# password: 1234
#####################
# The specified database role being used to connect to postgres.
# To create additional roles in postgres see `$ createuser --help`.
Expand Down Expand Up @@ -70,9 +70,8 @@ test:
# username: mymac
#####################
# Omar configuration
username: postgres
password: 1234

# username: postgres
# password: 1234
#####################
# As with config/credentials.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
Expand Down
15 changes: 15 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
Course.create(name: 'golf train', description: 'this is the first training course', location: 'Egypt', size: '5*6',
price: 455, image: 'https://images.freeimages.com/images/large-previews/1c6/golf-ball-in-the-fairway-1394202.jpg')

User.create(name:"test")
Reservation.create(date:"21-7-2022", city:"cairo",user_id: 1, course_id: 1)
Reservation.create(date:"22-5-2023", city:"Egypt",user_id: 1, course_id: 2)
User.create(name: 'test', role: 'admin')
Reservation.create(date: '21-7-2022', city: 'cairo', user_id: 1, course_id: 1)
Reservation.create(date: '22-5-2023', city: 'Egypt', user_id: 1, course_id: 2)

0 comments on commit d5a81b5

Please sign in to comment.