Created
January 5, 2012 10:22
-
-
Save mrnugget/1564609 to your computer and use it in GitHub Desktop.
Why do I need to use concat even though I use <%= %>?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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