1

Currently, I have a scope defined as following to query all records where the model OR it's child model have been updated:

scope :updated_after, ->(time) { 
   joins(:nested_resources).where("resources.updated_at > ? OR nested_resources.updated_at > ?", time, time) 
}

Is there a simpler way to do this?

skalb
  • 5,357
  • 3
  • 26
  • 23
  • simplicity is not measurable. so what exactly do you want to know? if you are talking about a nested resource, you could use `touch` to update the parent on save, but does that make it easier? no idea. – phoet Oct 22 '13 at 19:07
  • By simpler, I mean without having to write an explicit SQL string in the where clause. – skalb Oct 22 '13 at 19:11
  • you could use AREL http://stackoverflow.com/questions/7976358/activerecord-arel-or-condition – phoet Oct 22 '13 at 19:29

0 Answers0