I have a user model and I need to display all users that have an id of smaller than 100. My code is
User.where(:id < 100)
The error message is “comparison of Symbol with 100 failed”. How can I just get all users with ids smaller than 100? How will it be if I need ids between 100 and 200?
You need to drop into a SQL where clause for that:
But there’s a gem that will let you do what you’re trying to do: squeel. With that installed you could get the same result with:
For the range test:
or with squeel: