Reputation: 1023
I want to order my records with a condition. Lets say i have a Model
. And fields are [x,y,z]
.
These are all string typed colums. I want to sort records by condition
z = "YGS-1" and y DESC
for example. So z has a condition if value is "YGS-1" and y with DESC condition. How can i sort|order my records. with these conditions.
Any idea?
Thanks.
Upvotes: 0
Views: 316
Reputation: 10898
I'll assume your model is called Item
:
@items = Item.where(:z => "YGS-1").order("y DESC")
Upvotes: 1