Skip to content

Instantly share code, notes, and snippets.

@andhart
Last active September 6, 2022 16:56
Show Gist options
  • Save andhart/dc7f6d33e9da8e76d2a6d5598287ee11 to your computer and use it in GitHub Desktop.
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.
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
@andhart
Copy link
Author

andhart commented Sep 6, 2022

The Goal here is something like:

records = records .where("url ~ '?([\/?]|$)'", domain)

This doesn't work - but I'm looking for a similar solution.

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