title: Rails link_to with remote: true processing html instead of js after page refresh
body: <p>I have a search page in my app, where there is an ajax search form. The search form works properly, passing parameters to the model to filter the search, and the model returning a collection of results. Upon search submit, @results are rendered on the page. Each @result then has a link to an action on it, like:</p>
  
  <pre><code>&lt;%=link_to "Message", message_user_path(:id =&gt; user.id), :remote =&gt; true%&gt;
  </code></pre>
  
  <p>Where this action in the controller is:</p>
  
  <pre><code>respond_to :js, :html
  def message
    @user_id = params[:id]
    @user = User.find_by_id(@user_id)
    respond_to do |format|
      format.html
      format.js
    end
  end
  </code></pre>
  
  <p>and this responds with message.js.erb, which triggers a messaging panel to pop up with a message to the user. All of this is working correctly, checking the log I see the correct get request sent, and the correct format being processed:</p>
  
  <pre><code>Started GET "/users/3/message"
  Processing by UsersController#message as JS
  </code></pre>
  
  <p>However, if I refresh the page and try to click the same link that was working before, I get the error Template is Missing. Checking the log, I see that now there are two requests sent, first an html then the same js request.</p>
  
  <pre><code>Started GET "/users/4/message"
  Processing by StudentsController#message as HTML
  ...
  Completed 406 Not Acceptable in 3ms (ActiveRecord: 1.0ms)
  
  Started GET "/users/4/message"
  Processing by StudentsController#message as JS
  </code></pre>
  
  <p>The html request throws the missing template error. Does anyone know why refreshing the page causes rails to attempt to respond with an html request to a remote link?<br />
  EDIT: routes.rb</p>
  
  <pre><code>resources :students do
      member do
        get 'message'
      end
  end
  </code></pre>