Rails config hosts accepts regular expressions
Imagine you're running your Rails server on an ngrok instance. If you want to access your ngrok instance, you're going to need to add your specific ngrok subdomain to your config hosts.
If you ever restart your ngrok instance and get a new subdomain, you now have to change your config hosts again to match the new one.
Well, not anymore! Because now that you know you can use regular expressions, you can just do this:
Rails.application.config.hosts << /.*\.ngrok\.app/
Technically, if your use-case is just for subdomains, you can just do this:
Rails.application.config.hosts << ".ngrok.app"
But it's still nice to know you can utilize regular expressions if needed!
Tweet