Rails created_at find condition
I am trying to summarize the daily purchase amounts for a given user. @dates is an array of 31 dates. I need a search term to compare a date from an array to the created_at date of purchases. What I am doing below is comparing the exact DateTime value for the create_at column. I need it to look at the day and not the DateTime.
How can I write this so that created_at is between the date from the array?
<% @dates.each do |date| %>
<td><%= current_user.purchases.sum(:amount, :conditions => ["created_at = ?", date]) %></td>
<% end %>
+2
a source to share
2 answers