respond_to js "unknown format"
<p>I have this action in my PagesController:</p>

<pre><code>def webhook
  respond_to do |format|
    format.js
  end
end
</code></pre>

<p>I get an error <code>ActionController::UnknownFormat</code> when trying to access /webhook.</p>

<p>I have a webhook.js.erb file in my PagesController, and a route associated:<br>
<code>get '/webhook', to: 'pages#webhook'</code></p>

<p>I checked these posts: <a href="https://stackoverflow.com/questions/23590408/unknown-format-in-rails-4">Unknown format in rails 4</a> and <a href="https://stackoverflow.com/questions/27712859/rails-unknown-format-error-both-html-and-js">Rails Unknown format error (both HTML and JS)</a> but none had a working answer. </p>

<p>But
I used this syntax previously and it worked so I have no idea what's going on.</p>

<p>How could I fix this ? </p>

<p>EDIT:
Now, I've added <code>:format =&gt; :js</code> to my link_to, and when I click, the browser displays the js file webhook.js.erb
Here is my link_to: </p>

<pre><code> &lt;%= j link_to "Category", webhook_path(:format =&gt; :js), method: :post %&gt; 
</code></pre>

<p>I just have this in my webhook.js.erb to test it:</p>

<pre><code>alert("h");
</code></pre>

<p>What I expect is that when I click on my link, an alert shows up on the page</p>