Created
November 15, 2013 08:06
-
-
Save ppworks/7480800 to your computer and use it in GitHub Desktop.
link_to_ifにブロック渡した時の挙動が欲しいのと違う ref: http://qiita.com/ppworks/items/9bf917edf0d4927b15bd
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 ApplicationHelper | |
def link_to_if_with_block(condition, options = nil, html_options = nil, &block) | |
if condition | |
link_to(options, html_options, &block) | |
else | |
capture(&block) | |
end | |
end | |
end |
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
= link_to_if_with_block user_signed_in? user_path(current_user) do | |
.image | |
= user.image | |
.name | |
= user.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment