Rails - call method on a field within a where clause -


this question has answer here:

i want extract exchange rates today(ie. exchange rates have time field of type datetime , want extract day). want this:

exchangerates.where("time.day == ?", pred.time) 

is of kind possible?

your database doesn't have datetime object in works rails datetime object. in order query you'll have send understands, between clause. this:

exchangerates.where(time: pred.time.beginning_of_day..pred.time.end_of_day) 

i'm assuming pred datetime object


Comments

Popular posts from this blog

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -

javascript - three.js lot of meshes optimization -