Skip to content
Snippets Groups Projects
Commit 292557e3 authored by Israel Barreto Sant'Anna's avatar Israel Barreto Sant'Anna
Browse files

Merge branch 'issue/354' into 'master'

fixed return 404 instead of 500 when object doesn't exist

See merge request portalmec/portalmec!501
parents 8403a711 c4cf2095
No related branches found
No related tags found
No related merge requests found
image: ruby:2.3.1
services:
- postgres:9.5
- elasticsearch:2
......
......@@ -57,7 +57,7 @@ module SociableController
def view_object!
# Change request.remote_ip to req.env["HTTP_X_REAL_IP"] in production
sociable.view(current_user, request.remote_ip)
sociable.view(current_user, request.remote_ip) unless sociable.nil?
end
end
......@@ -132,10 +132,14 @@ class V1::LearningObjectsController < ApplicationController
def set_learning_object
#check if user is admin to show destroyed object
if current_user.try(:is_admin?)
@learning_object ||= LearningObject.unscoped.find(params[:id])
@learning_object ||= LearningObject.unscoped.find_by_id(params[:id])
else
@learning_object ||= LearningObject.find(params[:id])
@learning_object ||= LearningObject.find_by_id(params[:id])
end
if @learning_object.nil?
render status: :not_found
end
@learning_object
end
def set_new_learning_object
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment