Tidy up comments

This commit is contained in:
Jeffrey Hardy
2024-09-05 17:36:25 -04:00
parent 038a456392
commit 23248d8447
2 changed files with 5 additions and 6 deletions
+2 -4
View File
@@ -2,10 +2,8 @@ class CommentsController < ApplicationController
before_action :set_bubble
def create
@comment = @bubble.comments.create(comment_params)
@comment.save
redirect_to bubble_path(@bubble, anchor: "comment_#{@comment.id}")
@bubble.comments.create!(comment_params)
redirect_to @bubble
end
private
+3 -2
View File
@@ -5,8 +5,9 @@
<strong><%= Current.user.name %></strong>
</div>
<div class="comment__body txt-align-start">
<%= form_with model: [@bubble, @bubble.comments.build], class: "flex flex-column gap full-width" do | form | %>
<%= form.text_area :body, class: "input", required: true, placeholder: Current.user == @bubble.creator && @bubble.comments.size == 1 ? "Add some notes…" : "Type your comment…", rows: 4 %>
<%= form_with model: Comment.new, url: bubble_comments_path(@bubble), class: "flex flex-column gap full-width" do | form | %>
<%= form.text_area :body, class: "input", required: true, rows: 4,
placeholder: (@bubble.comments.empty? && @bubble.creator == Current.user) ? "Add some notes…" : "Type your comment…" %>
<%= form.button class: "btn btn--reversed center" do %>
<%= image_tag "check.svg", aria: { hidden: "true" }, size: 24 %>