Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. # frozen_string_literal: true
  2.  
  3. # :nodoc:
  4. class ActiveBussinessController < AplicationController
  5. def some_action
  6. # Dealing with params is a controller's responsibility
  7. arg = collect_and_validate_your_params
  8.  
  9. YourActiveBusinessImplementation.call(arg) do |resp|
  10. resp.success { |payload| render json: payload.to_json, status: 2xx }
  11. resp.error { |message| render json: { message: message }.to_json, status: 4xx }
  12. # You can define other outputs like an idempotent success
  13. resp.nothing_changed { head 204 }
  14. end
  15. rescue SomeException => ex
  16. # treat exception
  17. render json: "Something happened", status: 500
  18. end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement