I’m trying to get this to work:
link_to("#", class: "add_fields btn btn-success") do
name
content_tag(:i, "", :class => "icon-plus icon-white")
end
but it only shows me the icon specified by i (twitter-bootstrap css) and not the text in name, what am I doing wrong?
The return value of the block becomes its content. Only the last line is being returned.
You must concatenate the two strings together with
+to produce a single return value:You’ll need to use
html_safeto prevent the content of your tag from automatically being HTML encoded:Speaking from personal experience with Twitter Bootstrap, I know you will need a space between
nameandcontent_tag:Alternatively, if you are inside an ERB template, you can output both values with
<%=: