I am looping through an array in view, it works, but when I tried to move the code to helper method, it did not work. The problem is I am not able to do <%= %> inside helper. Anybody could let me know how to fix the code?
original view
<% resources.each do |resource| %>
<span class="label label-primary">
<%= resource.name %>
</span>
<% end %>
updated view
<%= print_resource resources%>
resource_helper.rb
def print_resource(resources)
resources.each do |resource|
text = resource.name
clz = 'label label-primary'
content_tag :span, text,clz
end
end
["<span class=\"label label-primary\">Update </span>", "<span class=\"label label-primary\">Delete</span>"']