Skip to content

Instantly share code, notes, and snippets.

@bibhuticoder
Created May 1, 2019 03:36
Show Gist options
  • Save bibhuticoder/669617a388e8ef28927cd76b2f54da76 to your computer and use it in GitHub Desktop.
Save bibhuticoder/669617a388e8ef28927cd76b2f54da76 to your computer and use it in GitHub Desktop.
class ExampleController < ApplicationController
def action_1
res_1; return if performed?
# rest of the logic....
render json: {data: '...'}, status: 200
end
def action_2
res_1; return if performed?
# rest of the logic....
render json: {data: '...'}, status: 200
end
def action_3
res_2; return if performed?
# rest of the logic....
render json: {data: '...'}, status: 200
end
def action_4
res_2; return if performed?
# 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