diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 7058ced2c..2bec3eb9f 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -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 diff --git a/app/views/comments/_new.html.erb b/app/views/comments/_new.html.erb index 0a4a1b955..24e59dfc9 100644 --- a/app/views/comments/_new.html.erb +++ b/app/views/comments/_new.html.erb @@ -5,8 +5,9 @@ <%= Current.user.name %>
- <%= 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 %>