Skip to content

Instantly share code, notes, and snippets.

@bandogora
Last active December 8, 2021 23:44
Show Gist options
  • Save bandogora/1858c793541ac1690092965c12b09786 to your computer and use it in GitHub Desktop.
Save bandogora/1858c793541ac1690092965c12b09786 to your computer and use it in GitHub Desktop.
Replace all Rails instances of `.try` with `&.`
# .try :method -> &.method
find ./ -type f -exec sed -ri 's/(.try\s*:)/\&./g' {} \;
# .try(:method) -> &.method
find ./ -type f -exec sed -ri 's/(.try\(?:)([^),]*)(\))/\&.\2/g' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment