Created
June 20, 2012 09:47
-
-
Save kirel/2959115 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module LinkToCondHelper | |
| # Alternative to link_to_if that actually works the way you expect | |
| # when using a block: If the condition passes wrap the block with a link. Otherwise just render it. | |
| # @param [Boolean] cond Condition to check if block should be linked or just rendered | |
| def link_to_cond cond, *args, &block | |
| if cond | |
| link_to *args, &block | |
| else | |
| capture &block | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment