Hi there! I've been working on a project using Rails and recently encountered an issue with Ajax requests when submitting forms for comments. After some trial and error, I managed to find a solution thanks to a helpful video tutorial I found here: https://www.youtube.com/watch?v=K-sns5tNdTY
More recently, I decided to expand the functionality by adding answers to the comments. This involved creating a new model and tweaking some CoffeeScript to display the answers and provide a form for responding to specific comments. It was quite challenging, but eventually, I got everything up and running smoothly.
However, I've run into a new issue where the comment form is not functioning properly through AJAX. While the comments are being posted, they are not getting appended to the comment list as expected.
When inspecting in Chrome, I noticed a console error:
jquery.self-bd7ddd3….js?body=1:10255 POST http://localhost:3000/comentarios 500 (Internal Server Error)
The code snippet below shows how I render the comments and the form (apologies for it being in Spanish):
<div id="seccion-comentarios" class="border-element-sm-div" style="overflow: hidden">
<h3 style="width: 500px">Comentarios</h3>
<div id="comentarios">
<%= render @comentarios %>
</div>
<% if @comentarios.count <= 0 %>
<p style="font-style: italic; color: grey; margin-left: 10px"> Aún no hay comentarios. Haz uno!</p>
<% end %>
<% if usuario_signed_in? %>
<div style="overflow: auto">
<%= render :partial => 'comentarios/form' %>
</div>
<% end %>
</div>
This is just a glimpse of the technical challenges I'm facing. Any assistance would be greatly appreciated!