I'm just learning how to move view code into decorators using the draper gem. I'm having trouble figuring out how to move .each into the decorator.
<% @project.users.each do |p| %>
<small class="btn btn-mini">
<%= link_to "#{p.first_name} #{p.last_name}", "mailto:#{p.email}" %>
</small>
<br>
<% end %>
I tried the following:
View code:
<%= @project.assigned_users %>
Decorator code:
def assigned_users
model.users.each do |p|
h.content_tag :small, class: 'btn btn-mini' do
h.link_to "#{p.first_name} #{p.last_name}", "mailto:#{p.email}"
end
end
end
The result is the entire user hash instead of the first_name last_name button I'm looking for. Maybe .each doesn't belong in the decorator? Any help would be appreciated.