Guest User

Untitled

a guest
Jan 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. @people = Person.where(conditions).includes(eager_fetch).all
  2.  
  3. @people = Person.where(conditions).all
  4. @fragments = {}
  5. @people.dup.each do |person|
  6. cache_key = "fragment-for-#{person.id}-#{person.updated_at.to_i}"
  7. fragment = Rails.cache.fetch(cache_key)
  8. unless fragment.nil?
  9. @fragments[person.id] = fragment
  10. @people.delete person
  11. end
  12. end
  13. @people = Person.where(:id => @people.collect(&:id)).includes(eager_fetch).all
  14.  
  15. Person.send :preload_associations, @people, eager_fetch
Add Comment
Please, Sign In to add comment