Reputation: 351
I'm creating like model in rails application. To use images in tooltip I need to wrap them all to:
<div class="tooltip">
The main method is:
def like_user_avatars
likes.map(&:user_avatar).map { |avatar| image_tag(avatar,
class: "tooltip_avatars") }.join
end
It generate something like this: <img src='...'><img src='...>
. I need to wrap them all to one div block named tooltip, it should looks like <div class="tooltip"><img src='...'><img src='...></div>.
I tried to add content tag :div, class: "tooltip", but it doesn't wrap everything. How can I solve my problem?
Upvotes: 2
Views: 83
Reputation: 5204
Use concat
to combine all images and wrap them into parent div
def like_user_avatars
content_tag :div, class: 'tooltip' do
likes.each do |like|
concat image_tag(like.user_avatar.avatar, class: "tooltip_avatars")
end
end
end
More about contact
and his usage
Upvotes: 2