Rails link_to with remote: true processing html instead of js after page refresh

Does your app/assets/javascripts/application.js contain

//= require jquery
//= require jquery_ujs 

?

And your erb contains <%= javascript_include_tag "application" %>?

I was just struggling with a problem like this for HOURS and the last of those two points fixed it; I saw the first point mentioned in some other questions so I'll repeat it here.

Hope that helps.

(Credit where credit's due)


What solver it for me was adding :format => "js"

So in your case:

<%=link_to "Message", message_user_path(:id => user.id, :format => "js"), :remote => true %>