Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
aoz-003
Commits
7329371d
Commit
7329371d
authored
May 30, 2017
by
Chrysanthi Lagodimou
Committed by
Tuğçe Nur Taş
Jun 02, 2017
Browse files
policies completed
parent
94d0a775
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/controllers/volunteers_controller.rb
View file @
7329371d
...
...
@@ -5,19 +5,26 @@ class VolunteersController < ApplicationController
def
index
@volunteers
=
Volunteer
.
all
authorize
Volunteer
end
def
show
;
end
def
show
authorize
@volunteer
end
def
new
@volunteer
=
Volunteer
.
new
@volunteer
.
schedules
<<
Schedule
.
build
authorize
@volunteer
end
def
edit
;
end
def
edit
authorize
@volunteer
end
def
create
@volunteer
=
Volunteer
.
new
(
volunteer_params
)
authorize
@volunteer
if
@volunteer
.
save
redirect_to
@volunteer
,
notice:
t
(
'volunteer_created'
)
else
...
...
@@ -26,6 +33,7 @@ class VolunteersController < ApplicationController
end
def
update
authorize
@volunteer
if
@volunteer
.
update
(
volunteer_params
)
if
@state
==
Volunteer
::
INTERESTED
&&
@volunteer
.
state
==
Volunteer
::
ACCEPTED
new_user
=
User
.
new
(
email:
@volunteer
.
email
,
...
...
@@ -42,6 +50,7 @@ class VolunteersController < ApplicationController
end
def
destroy
authorize
@volunteer
@volunteer
.
destroy
redirect_to
volunteers_url
,
notice:
t
(
'volunteer_destroyed'
)
end
...
...
app/policies/volunteer_policy.rb
View file @
7329371d
class
VolunteerPolicy
<
ApplicationPolicy
attr_reader
:user
attr_reader
:user
,
:volunteer
def
initialize
(
user
,
volunteer
)
@user
=
user
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment