Don't reload entire page when creating comment

This commit is contained in:
Kevin McConnell
2025-01-07 14:42:07 +00:00
parent 4a4b4113c8
commit 93536c3e41
5 changed files with 15 additions and 8 deletions
-1
View File
@@ -4,7 +4,6 @@ class CommentsController < ApplicationController
def create
@bubble.capture new_comment
redirect_to @bubble
end
def show
+11
View File
@@ -0,0 +1,11 @@
module MessagesHelper
def messages_tag(bubble, &)
turbo_frame_tag dom_id(bubble, :messages),
class: "comments align-center center borderless margin flex flex-column gap-half",
style: "--bubble-color: <%= bubble.color %>",
data: {
controller: "created-by-current-user",
created_by_current_user_mine_class: "comment--mine"
}, &
end
end
+2 -6
View File
@@ -1,10 +1,6 @@
<section id="<%= dom_id(bubble, :messages) %>"
class="comments align-center center borderless margin flex flex-column gap-half"
style="--bubble-color: <%= bubble.color %>"
data-controller="created-by-current-user"
data-created-by-current-user-mine-class="comment--mine">
<%= messages_tag(bubble) do %>
<%# Template Dependency: comments/comment %>
<%# Template Dependency: event_summaries/event_summary %>
<%= render bubble.messages, cached: true %>
<%= render "comments/new", bubble: bubble %>
</section>
<% end %>
+1
View File
@@ -0,0 +1 @@
<%= render "bubbles/messages", bubble: @bubble %>
+1 -1
View File
@@ -10,6 +10,6 @@ class CommentsControllerTest < ActionDispatch::IntegrationTest
post bucket_bubble_comments_url(buckets(:writebook), bubbles(:logo), params: { comment: { body: "Agreed." } })
end
assert_redirected_to bucket_bubble_url(buckets(:writebook), bubbles(:logo))
assert_response :success
end
end