0

I'm looking for a simple way to query updated_at through the associations of an ActiveRecord model. Specifically, I want to be able to query for the records OR related records (belongs_to, has_many) that have changed since a certain date.

I know that I could use the :touch option on the associations to update, but because I have lots of different relations so I don't want to do so — it would escalate quickly through cascading relationships.

Community
  • 1
  • 1
celeduc
  • 53
  • 6

1 Answers1

0

https://stackoverflow.com/a/12946091/2238259

Try the above, it provides a way to query for date ranges, you'll probably want a date X..Date.today

Community
  • 1
  • 1
Sherwyn Goh
  • 1,352
  • 1
  • 10
  • 19
  • Thanks — that's the query I need to look at the primary model, but it doesn't pick up the `updated_at` of the related records. This would only work if I put the `:touch` on each relationship (which I can't do). – celeduc Jan 30 '14 at 11:11