I have many models. Now I like to show the JavaScript to only the particular controller and method.
For example, if I had code like this and want to show it only in communities/show
Should I paste this in the head of view/communities/show.html.erb?
or is there smarter way to manage this kind of things?
Obviously it looks ugly if I put it in the head of show file because JavaScript always should be placed within < head> tag.
<%= javascript_tag do %>
jQuery(document).ready(function () {
refreshPartial();
setInterval(refreshPartial, 5000)
});
function refreshPartial() {
$.ajax({
url: "<%= community_path %>/refresh_part",
type: "GET",
dataType: "script",
});
}
<% end %>