Querying a number from a range in Rails -
say have item range in it:
item.rb :min_age # 3 :max_age # 7 :type :available
now have display item range.
currently doing this:
item.where(type: item_type.singularize.capitalize, available: true, min_age: age)
however display items within min_age..max_age range. tried conditions, apparently not doing right.
item.where(type: item_type.singularize.capitalize, available: true).where("min_age > ?", age).where("max_age < ?", age)
i think work.
Comments
Post a Comment