Reputation: 81
Say for example I have the following database of instances of a class called Obj
:
| id | attr1 |
+----+-------+
| 10 | A |
| 15 | B |
| 20 | C |
| 50 | D |
Now let's say I want to find all of the instances of Obj
with id greater than 10. How would I do that?
I want to write Obj.where(id > 10).all
. What is the proper way to accomplish this?
All help is appreciated. Thanks!
Upvotes: 0
Views: 31
Reputation: 8821
Have a try:
Obj.where("id > ?", 10)
you will find different ways to retrieve data from the database using Active Record from rails guide.
Upvotes: 1