class ExampleController < ApplicationController | |
def action_1 | |
if res1.eql?(false) | |
render json: {message: 'Failed'}, status: 400 unless res_1 | |
return | |
end | |
# rest of the logic.... | |
render json: {data: '...'}, status: 200 | |
end | |
def action_2 | |
if res1.eql?(false) | |
render json: {message: 'Failed'}, status: 400 unless res_1 | |
return | |
end | |
# rest of the logic.... | |
render json: {data: '...'}, status: 200 | |
end | |
def action_3 | |
if res2.eql?(false) | |
render json: {message: 'Failed'}, status: 400 unless res_2 | |
return | |
end | |
# rest of the logic.... | |
render json: {data: '...'}, status: 200 | |
end | |
def action_4 | |
if res2.eql?(false) | |
render json: {message: 'Failed'}, status: 400 unless res_2 | |
return | |
end | |
# rest of the logic.... | |
render json: {data: '...'}, status: 200 | |
end | |
private | |
def res_1 | |
# perform some operations | |
(operation1_successful?) ? true : false | |
end | |
def res_2 | |
# perform some operations | |
(operation2_successful?) ? true : false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment