Replace
Func.Create(text: "<% @users.each do |user| %>
<td><%= user.id %></td>
<td><%= link_to user.username, user_path(user) %></td>")
with
Func.Create(text: "<% if @users.nil? %>
<p> There are no users in database </p>
<% else %>
<% @users.each do |user| %>
<td><%= user.id %></td>
<td><%= link_to user.username, user_path(user) %></td><% end %> <% end %>")
<% end %>
end of block was missing.
Also, replace render :html => bar(binding)
with render :inline => bar(binding)
You could also shorten your code as below,
def foo
@users = User.all
html = Func.find(1)
render :inline => html.text
end