How would you approach adding comments/reply form to a JQuery slide-out panel for a model?

I’m currently using ‘acts_commentable_with_threading’ on my Post model.
I am able to add comments on the show.html.erb page for the posts. What
I’ve been trying to do is add this logic inside of the posts feed for
users. I can’t seem to add the comments form to the _feed_posts.html.erb
partial. Which has a slide-panel for commenting on user posts.

feed\index.html.erb

<%= render 'feed/feed_posts', following_activities: @following_activities %>

_feed_posts.html.erb

<% @following_activities.each do |post| %>
<%= link_to(image_tag(post.user.avatar.url(:thumb), class: 'round-image-50'), user_path(post.user), lazy: true) %>
<%= image_tag(post.photo.url(:medium), lazy: true) %>
<%= link_to(post.user.username, post.user) %>

<%= linkify_hashtags(post.body) %>
  • <% if current_user.liked? post %> <%= link_to dislike_post_path(post), class: 'fa fa-star fa-lg unlike_post', style: 'text-decoration: none; color: yellow;', method: :get do %> <%= post.get_likes.size %> <% end %> <% else %> <%= link_to like_post_path(post), class: 'fa fa-star fa-lg like_post', style: 'text-decoration: none; color: #494c4f;', title: 'like', method: :get do %> <%= post.get_likes.size %> <% end %> <% end %>
  • <% if post.user == current_user && user_signed_in? %><%= link_to 'Delete', post, method: :delete, data: {confirm: 'Are you sure?'}, style: 'color: darkred;' %> <% end %>
  • Reply <%= image_tag 'double-arrow-right.png' %>

Comments <%= post.comment_threads.count == 0 ? "0" : post.comment_threads.count %>

//Comments/reply form inside of slider

</div>
<% end %>

//Comments Partial Form {Doesn’t work in view, but has no issues in show
action for post.}

<%= form_for @new_comment do |f| %>
<%= f.hidden_field :commentable_id, value:
@new_comment.commentable_id %>
<%= f.hidden_field :commentable_type, value:
@new_comment.commentable_type %>


<%= f.text_area :body, class: ‘form-control’ %>


<%= submit_tag ‘Post comment’, class: ‘btn btn-primary-outline
btn-sm’ %>

//Comments _reply.html.erb

<% comments.each do |comment| %>




<%= comment.user.username.capitalize %>

<%= link_to(image_tag(comment.user.avatar_url(:thumb), class:
‘round-image-50’), user_path(comment.user)) %> <%= linkify_hashtags
comment.body %> <%= awesome_link ‘fa-times-circle’, comment, method:
:delete, remote: true, data: {disable_with: ‘Deleting Comment’}, style:
‘color: red;’ %>

    <div class="comment-nav"><a href="#" class="comment-reply"><i

class=“fa fa-reply”> Reply



<%= form_for @new_comment do |f| %>
<%= f.hidden_field :commentable_id, value:
@new_comment.commentable_id %>
<%= f.hidden_field :commentable_type, value:
@new_comment.commentable_type %>
<%= f.hidden_field :comment_id, value: comment.id %>
          <div class="field form-group">
            <%= f.text_area :body, class: 'form-control' %>
          </div>
          <div class="field form-group">
            <%= submit_tag 'Post Reply', class: 'btn btn-primary' %>
          </div>
      <% end %>
    </div>
  </div>
  <%= render partial: 'comments/reply', locals: {comments:

comment.children} %>


<% end %>

These two forms are actually brought together inside of a template
partial.

<%= commentable.comment_threads.count == 0 ? 'No New' : commentable.comment_threads.count %> Comments

<%= render partial: ‘comments/form’, locals: {new_comment: new_comment}
%>

<%= render partial: 'comments/reply', locals: {comments: commentable.root_comments} %>

//Renders comment/reply forms inside of one file
<%= render partial: ‘comments/template’, locals: {commentable: @post,
new_comment: @comment} %>

I need a form instance to populate each slider for each post. The
slide-out panel is working to an extent. It doesn’t populate with data
from nth elements. Only the top element on the page is loaded and I
cannot add comments to it. What approach would you take given the code
that I’ve shown you?

I clearly have to pass the id of each post to the JQuery slider itself.
Since the nth elements are showing the content hanging on the outside of
the object instances, and the reply button to activate the slider is not
working as well for them.