array = [#<Product id: 206, product: "first product", created_at: "2018-05-28 09:50:26", updated_at: "2018-05-28 09:50:26">, #<Product id: 207, product: "second product" ,created_at: "2018-05-28 09:50:46", updated_at: "2018-05-28 09:50:46"]
params[:from_date] = "2018-04-28 09:50:26"
params[:to_date] = "2018-05-28 09:50:46"
I'm filtering the above array with the following params (params[:from_date], params[:to_date]) using the below select statement.
array.select { |product| product.created_at >= params[:from_date] && product.created_at <= params[:to_date] }
I think there are more efficient methods than the above.
Are there any other methods to tackle this issue in a more efficient way?
(params[:from_date]..params[:to_date]).cover? product.created_atRange#include?performs additional checks for whether the range is integer (click on “view source”.)