Last active
September 6, 2022 16:56
-
-
Save andhart/dc7f6d33e9da8e76d2a6d5598287ee11 to your computer and use it in GitHub Desktop.
I have an SQL query defined below which is a regex looking for a domain. This works great, however, I'm trying to get where it says stripe.co to reflect the value of the variable 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
class PasswordsController < Test::BaseController | |
def index | |
records = AssetPassword.all | |
domain = "google.com" | |
records = records | |
.where("url ~ 'stripe.co([\/?]|$)'") | |
# the goal is to remove where it says stripe.co with a dynamic variable, so it could be ANY website/domain | |
render json: records | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Goal here is something like:
records = records .where("url ~ '?([\/?]|$)'", domain)
This doesn't work - but I'm looking for a similar solution.