Created
May 1, 2019 03:39
-
-
Save bibhuticoder/c2840fd1f728e45c1513938851accd8f to your computer and use it in GitHub Desktop.
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
class ExampleController < ApplicationController | |
before_action :res1, only: [:action_1, :action_2] | |
before_action :res2, only: [:action_3, :action_4] | |
def action_1 | |
# rest of the logic.... | |
render json: {data: '...'}, status: 200 | |
end | |
def action_2 | |
# rest of the logic.... | |
render json: {data: '...'}, status: 200 | |
end | |
def action_3 | |
# rest of the logic.... | |
render json: {data: '...'}, status: 200 | |
end | |
def action_4 | |
# rest of the logic.... | |
render json: {data: '...'}, status: 200 | |
end | |
private | |
def res_1 | |
# perform some operations | |
render json: {message: 'Failed'}, status: 400 unless operation1_successful? | |
end | |
def res_2 | |
# perform some operations | |
render json: {message: 'Failed'}, status: 400 unless operation1_successful? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment