I am encountering an issue with my form partial located within a div that has the id "chapcomments". The form includes a submit button:
<%= f.submit "Post", remote: true %>
Within the correct view folder, I have a file named create.js.erb which contains the following code:
$('#chapcomments').html("<%=j render 'shared/chap_comment_complete' %>");
In the controller, I have a format block for the create action:
def create
@chap_comment = current_user.chap_comments.build(chap_comment_params)
respond_to do |format|
if @chap_comment.save
format.js
format.html {redirect_to chapter_path(@chap_comment.chapter)}
else
format.html { render :new }
format.json { render json: @chap_comment.errors, status: :unprocessable_entity }
end
end
end
However, despite implementing these steps, I am not observing the desired ajax behavior. Can anyone pinpoint where I might be making a mistake?