Skip to content

Instantly share code, notes, and snippets.

@dgorodnichy
Last active July 16, 2020 12:24
Show Gist options
  • Save dgorodnichy/07d040b1d89c863fa6991cf38c089fbb to your computer and use it in GitHub Desktop.
Save dgorodnichy/07d040b1d89c863fa6991cf38c089fbb to your computer and use it in GitHub Desktop.
module Api
class LikesController < ApplicationController
def update
@user = User.find(params["user_id"])
@post = Post.find(params["post_id"])
result = ToggleLikeActionScript.new(@user, @post).perform
if result.success?
render json: { isLiked: result.value }
else
render json: { errors: result.errors }
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment