Created
September 13, 2020 17:35
-
-
Save arefaslani/7ccc3e88ec39d2f5dc092ed4c11d6bef to your computer and use it in GitHub Desktop.
Medium 702687394e3d-calling-the-service
This file contains hidden or 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 PostsController < ApplicationController | |
# ... | |
def create | |
Posts::Create.call(post_params.to_h) do |result| | |
result.success do |post| | |
render json: post, status: :ok | |
end | |
result.failure do |errors| | |
render json: errors, status: :unprocessable_entity | |
end | |
end | |
end | |
# ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment