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:
link_to("#", class: "add_fields btn btn-success") do
name + content_tag(:i, "", class: "icon-plus icon-white")
end
You'll need to use html_safe
to prevent the content of your tag from automatically being HTML encoded:
link_to("#", class: "add_fields btn btn-success") do
name + content_tag(:i, "", class: "icon-plus icon-white").html_safe
end
Speaking from personal experience with Twitter Bootstrap, I know you will need a space between name
and content_tag
:
link_to("#", class: "add_fields btn btn-success") do
name + ' ' + content_tag(:i, "", class: "icon-plus icon-white").html_safe
end
Alternatively, if you are inside an ERB template, you can output both values with <%=
:
<%= link_to( ... ) do %>
<%= name %>
<%= content_tag( ... ) %>
<% end %>