]> cat aescling's git repositories - mastodon.git/commitdiff
TIL a return from a block seems to return from the whole method rather than
authorEugen Rochko <eugen@zeonfederated.com>
Fri, 18 Mar 2016 23:23:46 +0000 (00:23 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 18 Mar 2016 23:23:46 +0000 (00:23 +0100)
the block, even though the last line of a block is an implicit return. I am
confused to say the least

app/helpers/application_helper.rb

index 56207c4bb534a6881759148a646b989850ad55e5..dad7ed349a2f36de4828fc0fca3a2d008debd3d0 100644 (file)
@@ -19,7 +19,7 @@ module ApplicationHelper
 
     auto_link(coder.encode(status.text), link: :urls, html: { rel: 'nofollow noopener' }).gsub(Account::MENTION_RE) do |m|
       account = mention_hash[Account::MENTION_RE.match(m)[1]]
-      return "#{m.split('@').first}<a href=\"#{url_for_target(account)}\" class=\"mention\">@<span>#{account.acct}</span></a>"
+      "#{m.split('@').first}<a href=\"#{url_for_target(account)}\" class=\"mention\">@<span>#{account.acct}</span></a>"
     end.html_safe
   end