def users_list
html = ''
self.users.each do |user|
html << user.link_avatar_tag
end
html.html_safe
end
I feel that it is possible to write shorter.
Is it possible get rid of the temporary variable(html)?
You should use map (don't use each to accumulate. Check this page about functional programming):
def users_list
users.map(&:link_avatar_get).join.html_safe
end
safe_join is not necessary, edited.
\$\endgroup\$
html_safeis no standard method for String - What gems are you using? Or in short: Can you provide a MWE? And to answer: It looks ok for me. \$\endgroup\$html_safecomes from. \$\endgroup\$self.users, is this a model? a helper? \$\endgroup\$