I was thinking about this recently, but was toying around with a
different, possibly more flexible syntax...

:conditions => {:comments => {:created_at ' => 14.days.ago..7.days.ago}}

Combined with normal conditions...

:conditions => {:field => value, :comments => {:created_at ' =>
14.days.ago..7.days.ago}}

You could nest as deep as you like in the same way :include works.

Any issues with this approach instead?

Andrew

On 9/28/07, Jack Danger Canty <[EMAIL PROTECTED]> wrote:
> Ahoy!
>
> Have you guys ever needed to do this?:
>
> Post.find(:all, ;include => :comments, :conditions => {'comments.created_at
> ' => 14.days.ago..7.days.ago})
>
> Well, I certainly have.  And I finally got around to patching
> sanitize_sql_hash_for_conditions() so rather than doing
> this:
> "SELECT ... WHERE posts.`comments.created_at` BETWEEN ..."
> it provides us with:
> "SELECT ... WHERE comments.created_at BETWEEN ..."
>
>
> And you can have the whole package for the low, low price of a +1.
>
> http://dev.rubyonrails.org/ticket/9733
>
> ::Jack Danger
>  >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to