Rails created_at find condition...

Posted by Dustin Brewer on Stack Overflow See other posts from Stack Overflow or by Dustin Brewer
Published on 2010-05-02T17:02:54Z Indexed on 2010/05/02 17:08 UTC
Read the original article Hit count: 268

Filed under:
|
|
|
|

I'm attempting to sum daily purchase amounts for a given user. @dates is an array of 31 dates. I need the find condition to compare a date from the array to the created_at date of the purchases. What I'm doing below compares the exact DateTime for the create_at column. I need it to look at the day itself, not the DateTime.

How can I write this so created_at is in between the date from the array?

<% @dates.each do |date| %>

<%= current_user.purchases.sum(:amount, :conditions => ["created_at = ?", date]) %> <% end %>

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby