This should be a no-op change that allows for performance improvements by preloading the audits association. By checking if the audits association is already loaded, we can avoid N+1 queries by operating on the already loaded audits in ruby instead of going to the database again to check if a version exists, etc.
This code should be functionally identical to the existing code, but allows for something like:
@posts = Post.all.include(:audits)
@posts_at_v1 = @posts.map do |post|
post.revision(1)
end
This should be a no-op change that allows for performance improvements by preloading the
audits
association. By checking if theaudits
association is already loaded, we can avoid N+1 queries by operating on the already loaded audits in ruby instead of going to the database again to check if a version exists, etc.This code should be functionally identical to the existing code, but allows for something like:
To avoid repeated database access.