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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -