リア充爆発日記

You don't even know what ria-ju really is.

railsのlink_to_ifにブロックを渡す

link_toにlink_to_ifはあるけど、これにブロックを渡す方法がない。

ので、つくろうと思ったらもう作っている人がいた。
http://stackoverflow.com/questions/10305180/rails-how-can-i-show-a-block-with-or-without-a-link-based-on-a-condition-link

丸パクだ!

  def link_to_if_with_block condition, options, html_options={}, &block
    if condition
      link_to options, html_options, &block
    else
      capture &block
    end
  end