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
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
<% if CurrentUser.is_member? %>
|
||||
<td>
|
||||
<% 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 %>
|
||||
|
||||
Reference in New Issue
Block a user