about summary refs log tree commit diff
path: root/app/controllers/api_controller.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-08-26 19:12:19 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-08-26 19:12:19 +0200
commit92afd296509de82e7550f67064b032db916b1f63 (patch)
tree6d723210f723d0a74317805352e7912b70c54240 /app/controllers/api_controller.rb
parent44e57f64dd8b00900c31d7fd56fda94f4e69e986 (diff)
The frontend will now be an OAuth app, auto-authorized. The frontend will use an access token for API requests
Adding better errors for the API controllers, posting a simple status works from the frontend now
Diffstat (limited to 'app/controllers/api_controller.rb')
-rw-r--r--app/controllers/api_controller.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index 8a2712476..bacdd997b 100644
--- a/app/controllers/api_controller.rb
+++ b/app/controllers/api_controller.rb
@@ -2,6 +2,14 @@ class ApiController < ApplicationController
   protect_from_forgery with: :null_session
   skip_before_action :verify_authenticity_token
 
+  rescue_from ActiveRecord::RecordInvalid do
+    render json: { error: 'Record invalid' }, status: 422
+  end
+
+  rescue_from ActiveRecord::RecordNotFound do
+    render json: { error: 'Record not found' }, status: 404
+  end
+
   protected
 
   def current_resource_owner