Created
January 5, 2023 13:27
-
-
Save narath/2c39f95fc3994662de6f06c98b0d2ed4 to your computer and use it in GitHub Desktop.
Regular expression for changing the localhost domain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in general you should never need to use this in Rails | |
# since you should use the url helpers | |
# this is a really helpful post about how to do this elegantly with a concern | |
# https://andycroll.com/ruby/url-helpers-outside-views-controllers/ | |
def change_localhost_domain(url, new_domain) | |
url.gsub(/http:\/\/localhost:3000|http:\/\/127.0.0.1:3000/, new_domain) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment