To make sure I sent a response that included JavaScript code, I created a template with the .js.erb template extension.
When a submitted comment fails validation, I also want to warn the user by displaying error. A specific template
New comment template
app/views/articles/show.html.erb
Updated to respond to JS and HTML requests
Telling Rails I want the form data to be submitted via Ajax