Reputation: 3298
I have a code that needs to be split into two lines so it looks nice. However when I try:
link_to "Some Text<br />Here",url_path
it will output the HTML too, even if I use html.html_safe like so:
html = ""
html += link_to "Some Text<br />Here",url_path
html.html_safe
How can I make it so "Here" will appear on a new line?
Upvotes: 10
Views: 6017
Reputation: 12397
A trick most Rails developers don't know is that link_to
accepts a block:
<%= link_to(url_path) do %>
Some Text
<br />
Here
<% end %>
Upvotes: 19