diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c1959f48f..1c1fd4688d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ - Refactor Plan.deep_copy(plan) [#3469](https://github.com/DMPRoadmap/roadmap/pull/3469) - Fixed a bug in the deep copy of plans where the old identifier was being copied into the new plan. We now copy the generated id of the new plan to the identifier field. - Fixed bar chart click function in the Usage dashboard (GitHub issue #3443) - +- Fix `Template.latest_version` Ambiguity Error [#3474](https://github.com/DMPRoadmap/roadmap/pull/3474) **Note this upgrade is mainly a migration from Bootstrap 3 to Bootstrap 5.** diff --git a/app/models/template.rb b/app/models/template.rb index 4e83978b6e..c698367ad5 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -136,6 +136,10 @@ class Template < ApplicationRecord AND current.family_id = templates.family_id INNER JOIN orgs ON orgs.id = templates.org_id SQL + # `SELECT "templates.*"` is this scope's default behavior, but it must be explicitly + # specified to prevent `PG::AmbiguousColumn` errors when `.distinct.total_count` is used + # (e.g. in `app/views/layouts/_paginable.html.erb`) + .select('templates.*') } # Retrieves the latest customized versions, i.e. those with maximum version