Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created June 24, 2016 04:12
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 anonymous/61c23405aaeb0b5561cc642f4f333d13 to your computer and use it in GitHub Desktop.
Save anonymous/61c23405aaeb0b5561cc642f4f333d13 to your computer and use it in GitHub Desktop.
query using LIKE
# Use the `LIKE` operator in SQL to find all cars with conditions that contain "good"
# assign to `your_cars` variable
def test_like
your_cars = []
cars = []
cars << Car.create(:condition => "goodish")
cars << Car.create(:condition => "very good")
cars << Car.create(:condition => "not so good")
Car.create(:condition => "straight up bad")
# put your code here
your_cars = Car.where("cars LIKE ?", "%#{good%}" )
assert_equal cars, your_cars
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment