diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-18 15:33:34 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-18 15:33:34 -0500 |
commit | 8cea8ae278c0e0417e5d58a387cc5d31c0590251 (patch) | |
tree | 9b202cb3221a6694049605dfa3e20a6fdf5b351d /actionview/lib | |
parent | 4279a75a144515d1a35f8617f0ef61ddec33e7fd (diff) | |
parent | 4f90298d3752bb244d882374b16a0c6b06932b31 (diff) | |
download | rails-8cea8ae278c0e0417e5d58a387cc5d31c0590251.tar.gz rails-8cea8ae278c0e0417e5d58a387cc5d31c0590251.tar.bz2 rails-8cea8ae278c0e0417e5d58a387cc5d31c0590251.zip |
Merge pull request #14421 from davidpdrsn/reorder-conditionals
Reorder conditional logic in link_to_if and link_to_unless
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/helpers/url_helper.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb index 51379d433f..89c196e578 100644 --- a/actionview/lib/action_view/helpers/url_helper.rb +++ b/actionview/lib/action_view/helpers/url_helper.rb @@ -389,15 +389,7 @@ module ActionView # # If not... # # => <a href="/accounts/signup">Reply</a> def link_to_unless(condition, name, options = {}, html_options = {}, &block) - if condition - if block_given? - block.arity <= 1 ? capture(name, &block) : capture(name, options, html_options, &block) - else - ERB::Util.html_escape(name) - end - else - link_to(name, options, html_options) - end + link_to_if !condition, name, options, html_options, &block end # Creates a link tag of the given +name+ using a URL created by the set of @@ -421,7 +413,15 @@ module ActionView # # If they are logged in... # # => <a href="/accounts/show/3">my_username</a> def link_to_if(condition, name, options = {}, html_options = {}, &block) - link_to_unless !condition, name, options, html_options, &block + if condition + link_to(name, options, html_options) + else + if block_given? + block.arity <= 1 ? capture(name, &block) : capture(name, options, html_options, &block) + else + ERB::Util.html_escape(name) + end + end end # Creates a mailto link tag to the specified +email_address+, which is |