Skip to content

Instantly share code, notes, and snippets.

@arefaslani
Created September 13, 2020 17:35
Show Gist options
  • Save arefaslani/7ccc3e88ec39d2f5dc092ed4c11d6bef to your computer and use it in GitHub Desktop.
Save arefaslani/7ccc3e88ec39d2f5dc092ed4c11d6bef to your computer and use it in GitHub Desktop.
Medium 702687394e3d-calling-the-service
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