link_to_if, link_to_unless, link_to_unless_current
こんな便利なのがあるとは。
今まで
<%= params[:action]=="index" ? "戻る" : link_to("戻る",:action=>"index") %>
などと書いていたのに
<%= link_to_unless params[:action]=="index","戻る",:action=>"index"%>
などとDRYに書けるメソッドがすでにあったようです。
こんな便利なのがあるとは。
今まで
<%= params[:action]=="index" ? "戻る" : link_to("戻る",:action=>"index") %>
などと書いていたのに
<%= link_to_unless params[:action]=="index","戻る",:action=>"index"%>
などとDRYに書けるメソッドがすでにあったようです。