1

アプリのヘッダーにあるユーザー ドロップダウン メニューに以下の行があります。

<%= link_to "profile (#{user.notifications.count})", current_user %>

これはprofile (3)、ユーザーに 3 つの通知がある場合に表示されます。profileとは違う色に染めたい(3)

2つの異なる部分に異なるクラスを与えるためにこれを行う最良の方法はありますか? もしそうなら、どうすればそれを行うことができますか?

4

2 に答える 2

2

それを達成する簡単な方法は、次spanのように使用することです

<%= link_to raw("<span style='color: #000'>profile</span> (#{user.notifications.count})"), current_user %>

または、インライン CSS を挿入したくない場合は、次のようにします。

<%= link_to raw("<span class='your_profile_class'>profile</span> (#{user.notifications.count})"), current_user %>
于 2013-05-07T18:56:05.393 に答える