Created
June 24, 2016 04:12
-
-
Save anonymous/61c23405aaeb0b5561cc642f4f333d13 to your computer and use it in GitHub Desktop.
query using LIKE
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
# 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