Answer the question
In order to leave comments, you need to log in
How to filter by a given range in Rails?
Good afternoon. I have an Entry model with date and time attributes (date and time of creation). On the index page, you need to make a filter with 4 fields that would accept the start date and start time, as well as the end date and end time, and search for records in the specified range. I don't know how to do it.
Answer the question
In order to leave comments, you need to log in
You get the required values through params.
Then a simple query Entry.find(:all).where(:date => start_date..end_date).where(:time => start_time..end_time)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question