Skip to content

Commit 13391b5

Browse files
committed
API Fix
1 parent 16f432d commit 13391b5

File tree

6 files changed

+24
-4
lines changed

6 files changed

+24
-4
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ gem 'puma', '~> 3.11'
2020

2121
gem 'jwt'
2222
gem 'active_model_serializers'
23+
gem "pry"
2324

2425

2526
# Use ActiveStorage variant

Gemfile.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ GEM
6565
byebug (11.0.0)
6666
case_transform (0.2)
6767
activesupport
68+
coderay (1.1.2)
6869
concurrent-ruby (1.1.4)
6970
crass (1.0.4)
7071
erubi (1.8.0)
@@ -96,6 +97,9 @@ GEM
9697
nokogiri (1.10.1)
9798
mini_portile2 (~> 2.4.0)
9899
pg (1.1.4)
100+
pry (0.12.2)
101+
coderay (~> 1.1.0)
102+
method_source (~> 0.9.0)
99103
puma (3.12.0)
100104
rack (2.0.6)
101105
rack-cors (1.0.2)
@@ -163,6 +167,7 @@ DEPENDENCIES
163167
knock!
164168
listen (>= 3.0.5, < 3.2)
165169
pg (>= 0.18, < 2.0)
170+
pry
166171
puma (~> 3.11)
167172
rack-cors
168173
rails (~> 5.2.2)

app/controllers/api/v1/breaks_controller.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1+
require "pry"
12
class Api::V1::BreaksController < ApplicationController
23

34

45
# GET /breaks
6+
57
def index
6-
@breaks = Break.all
8+
9+
@breaks = get_current_user.managers.map{|manager| manager.breaks }.flatten
10+
11+
712

813
render json: @breaks
14+
915
end
1016

17+
1118
# GET /breaks/1
1219
def show
1320
render json: @break
21+
1422
end
1523

1624
# POST /breaks
@@ -35,6 +43,7 @@ def update
3543

3644
# DELETE /breaks/1
3745
def destroy
46+
@break = Break.find(params[:id])
3847
@break.destroy
3948
end
4049

app/controllers/api/v1/companies_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ class Api::V1::CompaniesController < ApplicationController
33

44
# GET /companies
55
def index
6-
@companies = Company.all
6+
@companies = get_current_user.companies
7+
78

89
render json: @companies
910
end
@@ -35,6 +36,7 @@ def update
3536

3637
# DELETE /companies/1
3738
def destroy
39+
@company = Company.find(params[:id])
3840
@company.destroy
3941
end
4042

app/controllers/api/v1/employees_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Api::V1::EmployeesController < ApplicationController
33

44
# GET /employees
55
def index
6-
@employees = Employee.all
6+
@employees = get_current_user.employees
77

88
render json: @employees
99
end
@@ -35,6 +35,8 @@ def update
3535

3636
# DELETE /employees/1
3737
def destroy
38+
@employee = Company.find(params[:id])
39+
3840
@employee.destroy
3941
end
4042

app/controllers/api/v1/managers_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Api::V1::ManagersController < ApplicationController
33

44
# GET /managers
55
def index
6-
@managers = Manager.all
6+
@managers = get_current_user.managers
77

88
render json: @managers
99
end
@@ -35,6 +35,7 @@ def update
3535

3636
# DELETE /managers/1
3737
def destroy
38+
@manager = Manager.find(params[:id])
3839
@manager.destroy
3940
end
4041

0 commit comments

Comments
 (0)