1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Use #tr instead of #gsub where possible

This commit is contained in:
Alex Weidmann 2014-10-02 17:35:13 -06:00
parent 4cd57a88b4
commit afb92754c8
2 changed files with 2 additions and 2 deletions

View file

@ -862,7 +862,7 @@ module ActionView
# see http://www.w3.org/TR/html4/types.html#type-name # see http://www.w3.org/TR/html4/types.html#type-name
def sanitize_to_id(name) def sanitize_to_id(name)
name.to_s.delete(']').gsub(/[^-a-zA-Z0-9:.]/, "_") name.to_s.delete(']').tr('^-a-zA-Z0-9:.', "_")
end end
end end
end end

View file

@ -321,7 +321,7 @@ module ActionView
end end
def identifier_method_name #:nodoc: def identifier_method_name #:nodoc:
inspect.gsub(/[^a-z_]/, '_') inspect.tr('^a-z_', '_')
end end
def instrument(action, &block) def instrument(action, &block)