-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
class ApplicationController < ActionController::Base | ||
include DeviseTokenAuth::Concerns::SetUserByToken | ||
# Prevent CSRF attacks by raising an exception. | ||
# For APIs, you may want to use :null_session instead. | ||
protect_from_forgery with: :null_session | ||
include DeviseTokenAuth::Concerns::SetUserByToken | ||
|
||
protect_from_forgery with: :null_session | ||
|
||
rescue_from ActionController::ParameterMissing, with: :invalid_params | ||
rescue_from ActiveRecord::RecordNotFound, with: :not_found | ||
|
||
def render_error_messages(object, status=:unprocessable_entity) | ||
render json: { :errors => object.errors.messages, :fields=>object.errors.keys }, | ||
status: status, head: status | ||
end | ||
|
||
def render_blank_success | ||
render json: {}, status: :ok | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
end | ||
|
||
def invalid_params(exception) | ||
render json: { errors: "Required parameter is missing: #{exception.param}" }, status: :unprocessable_entity, head: :unprocessable_entity | ||
end | ||
|
||
def not_found | ||
render json: { errors: "Item not found" }, status: :not_found, head: :not_found | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
я бы все-таки отправлял в боди success: true. Чтобы другим понятнее было.