2012-02-22 9 views
1

link_toコールの中に追加のHTMLを埋め込むにはどうすればよいですか?link_toコールの中に追加のHTMLを埋め込む

<a href="/exercies/show/1"><i class="icon-show"></i>Show</a> 

はここでそれがエスケープされないように

<%= link_to "Show", exercise_path(exercise) %> 
+3

ブロックする場合それはきれいです!これをチェックしてください: http://stackoverflow.com/questions/9401942/using-link-to-with-embedded-html – Veraticus

答えて

4
<%= link_to '<i class="icon-search"></i> Show'.html_safe, exercise_path(exercise), :class => 'btn btn-small' %> 

.html_safeが必要とされ、私のlink_toの呼び出しです:

は、ここに私の望ましい結果です。

0

あなたがそれを包む私はこれだけで今日早く答え

<%= link_to exercise_path(exercise) do %> <i class="icon-search"></i> Show <% end %>

関連する問題