Last active
August 29, 2015 14:03
-
-
Save sebyx07/c7a6ef2d3e0431521876 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def render_error(options={}) | |
errors = options[:error] || '' | |
message = options[:message] || '' | |
action = options[:action] || '' | |
render json: {errors:{ errors: errors, message: message, action: action}}, status: 422 | |
end | |
def render_success(options={}) | |
action = options[:action] || '' | |
render json: {action: action} | |
end | |
def require_login | |
unless signed_in? | |
render_error(message: 'not logged in') | |
end | |
end | |
#error response: {"errors":{"errors":"","message":"not logged in","action":""}} | |
#success response: {"action":"created"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
looks good