change useless gsub to tr #9564

Merged
merged 1 commit into from Mar 5, 2013

3 participants

@robertomiranda

Consistent with past commits such as 2d8396f & c614711

@guilleiguaran guilleiguaran commented on an outdated diff Mar 5, 2013
...spatch/middleware/templates/rescues/routing_error.erb
@@ -8,7 +8,7 @@
<h2>Failure reasons:</h2>
<ol>
<% @exception.failures.each do |route, reason| %>
- <li><code><%= route.inspect.gsub('\\', '') %></code> failed because <%= reason.downcase %></li>
+ <li><code><%= route.inspect.tr('\\', '') %></code> failed because <%= reason.downcase %></li>
@guilleiguaran
Ruby on Rails member
guilleiguaran added a line comment Mar 5, 2013

use delete here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@robertomiranda

done 👍

@guilleiguaran guilleiguaran merged commit 588f267 into rails:master Mar 5, 2013
@robertomiranda robertomiranda deleted the robertomiranda:useless_gsub branch Mar 5, 2013
@teeparham

This will not work. tr does not work like gsub when the to_str is longer than the from_str. See

For example:

> "yo  dawg".tr("  ", "&nbsp; ")
 => "yonndawg"

> "yo  dawg".gsub("  ", "&nbsp; ")
 => "yo&nbsp; dawg"
@teeparham

@robertomiranda Thanks. I think the same problem exists on 2 of the other tr calls. See this comment: 588f267#commitcomment-2746016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment