V
V
V2016-07-31 13:12:29
Ruby on Rails
V, 2016-07-31 13:12:29

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

1 answer(s)
C
Chronic 86, 2016-07-31
@ermolushka

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 question

Ask a Question

731 491 924 answers to any question