samedi 16 mai 2015

Find a Portion of a Database in Ruby

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!

Aucun commentaire:

Enregistrer un commentaire