0

有没有办法在下面的link_to_unless_current 中添加一个图标?我需要在当前和非当前状态下添加它。

= link_to_unless_current("Stats", stats_practice_path(current_user.practice)) do content_tag(:div, content_tag(:p, "Stats"), :class => "nav-active") end
4

1 回答 1

0

我认为您为此使用了辅助方法。

前任:

module ApplicationHelper

   def icon(image = "youricon.png")
     raw(image_tag(image)) 
   end

end

在您看来:

= link_to_unless_current(icon, stats_practice_path(current_user.practice)) do content_tag(:div, content_tag(:p, "Stats"), :class => "nav-active") end

(注意:我自己没有对此进行测试,我认为它应该可以工作:))

于 2013-04-17T04:21:45.560 回答