From 3290f5550aa90d569d9a19547368fdc58a66a4fd Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 2 Mar 2017 16:56:09 -0600 Subject: [PATCH] post_versions/_listing.html.erb:40: fix N+1 queries in "Undo" link. post_version.post.versions.first.id caused an extra query for each post version: SELECT "post_versions".* FROM "post_versions" WHERE "post_versions"."post_id" = $1 ORDER BY updated_at ASC, id asc LIMIT 1 --- app/views/post_versions/_listing.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/post_versions/_listing.html.erb b/app/views/post_versions/_listing.html.erb index ed5ff4178..39ab5026b 100644 --- a/app/views/post_versions/_listing.html.erb +++ b/app/views/post_versions/_listing.html.erb @@ -37,7 +37,7 @@ <% if CurrentUser.is_member? %> <% if post_version.post.visible? %> - <% if post_version.id != post_version.post.versions.first.id %> + <% if post_version.version != 1 %> <%= link_to "Undo", undo_post_version_path(post_version), :method => :put, :remote => true %> | <% end %> <%= link_to "Revert to", revert_post_path(post_version.post_id, :version_id => post_version.id), :method => :put, :remote => true %>