Skip to content

Instantly share code, notes, and snippets.

@dleve123
Created May 10, 2016 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dleve123/98f8b01d7c17543f15391b0a0ec44401 to your computer and use it in GitHub Desktop.
Save dleve123/98f8b01d7c17543f15391b0a0ec44401 to your computer and use it in GitHub Desktop.
String Types Matter For Complicated ActiveRecord Queries
[29] pry(main)> Clinic.where("subdomain LIKE ?", "%\_%")
=> [#<Clinic:0x007f8212b97b98
id: 1,
name: "Factory Clinic 1",
subdomain: "factory-clinic-1",
privacy_policy: nil,
optional_data_sharing: false,
automated_texting: false,
company_id: 2>,
#<Clinic:0x007f8212b97a08
id: 2,
name: "Factory Clinic 2",
subdomain: "factory-clinic-2",
privacy_policy: nil,
optional_data_sharing: false,
automated_texting: false,
company_id: 2>]
[30] pry(main)> Clinic.where("subdomain LIKE ?", '%\_%')
=> []
# Note that the query on L30 has the expected output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment