Skip to content

Instantly share code, notes, and snippets.

@mrnugget
Created January 5, 2012 10:22
Show Gist options
  • Save mrnugget/1564609 to your computer and use it in GitHub Desktop.
Save mrnugget/1564609 to your computer and use it in GitHub Desktop.
Why do I need to use concat even though I use <%= %>?
# Partial: /views/songs/_song_info.html.erb
<div class="song_info">
<div class="tags">
<h4>Tags:</h4>
<p><%= render_tags @song %></p>
</div>
</div>
# Helper Method: /helpers/songs_helper.rb
def render_tags(song)
if song.tags.any?
song.tags.each { |tag| concat content_tag :span, tag.name, class: "tag" }
else
# Why do I need to use 'concat' here?
concat content_tag :span, "This song has no tags! Add some!", class: "no-tags"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment