Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # frozen_string_literal: true
- # :nodoc:
- class ActiveBussinessController < AplicationController
- def some_action
- # Dealing with params is a controller's responsibility
- arg = collect_and_validate_your_params
- YourActiveBusinessImplementation.call(arg) do |resp|
- resp.success { |payload| render json: payload.to_json, status: 2xx }
- resp.error { |message| render json: { message: message }.to_json, status: 4xx }
- # You can define other outputs like an idempotent success
- resp.nothing_changed { head 204 }
- end
- rescue SomeException => ex
- # treat exception
- render json: "Something happened", status: 500
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement