Infinity Loop in background in html.erb - how?

How to make infinity loop in background?
In my application.html.erb i want to make this endless:(get_dialogs and
the
subscribe_to)

<% user.get_dialogs do |dialog| %>
<%= subscribe_to “/dialogs/#{dialog[:id]}” %>
<% end %>

Of`course, on client side i am using setInterval , but on server side