Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
4f2be9a5
Commit
4f2be9a5
authored
8 years ago
by
Marcela Ribeiro de Oliveira
Browse files
Options
Downloads
Patches
Plain Diff
update review controller
parent
2e6079eb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/v1/reviews_controller.rb
+22
-2
22 additions, 2 deletions
app/controllers/v1/reviews_controller.rb
with
22 additions
and
2 deletions
app/controllers/v1/reviews_controller.rb
+
22
−
2
View file @
4f2be9a5
...
@@ -2,8 +2,8 @@ class V1::ReviewsController < ApplicationController
...
@@ -2,8 +2,8 @@ class V1::ReviewsController < ApplicationController
include
::
DeletedObjectsController
include
::
DeletedObjectsController
include
::
ResourceModel
include
::
ResourceModel
before_action
:set_review
,
only:
[
:show
,
:destroy
,
:rate
]
before_action
:set_review
,
only:
[
:show
,
:destroy
,
:rate
,
:update
]
before_action
:authenticate_user!
,
only:
[
:create
,
:rate
,
:destroy
]
before_action
:authenticate_user!
,
only:
[
:create
,
:rate
,
:destroy
,
:update
]
# GET /v1/collections/1/reviews
# GET /v1/collections/1/reviews
def
index
def
index
...
@@ -29,6 +29,26 @@ class V1::ReviewsController < ApplicationController
...
@@ -29,6 +29,26 @@ class V1::ReviewsController < ApplicationController
end
end
end
end
# PUT /v1/learning_objects/1/reviews/1
# PUT /v1/learning_objects/1/reviews/1.json
def
update
ratings_params
=
review_params
rp
=
ratings_params
.
delete
(
:review_ratings_attributes
)
if
@review
.
update
(
ratings_params
)
@review
.
review_ratings
.
each
do
|
r
|
rp
.
each
do
|
s
|
if
r
.
rating_id
==
s
[
:rating_id
]
r
.
value
=
s
[
:value
]
r
.
save
end
end
end
render
json:
@review
,
status: :ok
else
render
json:
@review
.
errors
,
status: :unprocessable_entity
end
end
def
process_creation
(
review
)
def
process_creation
(
review
)
# Store errors
# Store errors
errors
=
[]
errors
=
[]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment