Class: Bible270::LikesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/bible270/likes_controller.rb

Overview

A heart on someone's reflection. One route, because liking and unliking are the same gesture — tapping the heart again takes it back.

Instance Method Summary collapse

Instance Method Details

#toggleObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/bible270/likes_controller.rb', line 7

def toggle
  return unless require_reader!

  @comment = Comment.approved.find_by(id: params[:id])
  head :not_found and return unless @comment

  @comment.toggle_like!(current_reader)
  @comment.reload

  respond_to do |format|
    format.turbo_stream
    format.html { redirect_to day_path(@comment.day, anchor: "comment-#{@comment.id}") }
  end
end