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

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -