diff --git a/app/models/guidance.rb b/app/models/guidance.rb index 5e33aec..b6048f4 100644 --- a/app/models/guidance.rb +++ b/app/models/guidance.rb @@ -46,6 +46,7 @@ # @return [Array] list of guidance def self.by_organisation(org_id) org_guidance = [] + # TODO: re-write below querry when guidance_in_group removed from model Org.find_by(id: org_id).guidance_groups.each do |group| org_guidance += Guidance.where(guidance_group_id: group.id) end diff --git a/app/policies/guidance_policy.rb b/app/policies/guidance_policy.rb index 6fdab13..4aa8245 100644 --- a/app/policies/guidance_policy.rb +++ b/app/policies/guidance_policy.rb @@ -53,7 +53,7 @@ class Scope < Scope def resolve - scope = Guidance.by_organisation(user.org_id) + scope = Guidance.includes(:guidance_group, :question, :themes).by_organisation(user.org_id) end end end \ No newline at end of file diff --git a/app/views/guidances/admin_index.html.erb b/app/views/guidances/admin_index.html.erb index 4c0130f..a660213 100644 --- a/app/views/guidances/admin_index.html.erb +++ b/app/views/guidances/admin_index.html.erb @@ -16,16 +16,15 @@ -<% if @guidance_groups.count > 0 then%> +<% if @guidance_groups.length > 0 then%> - - - - - - + + + + + @@ -85,7 +84,7 @@
-<% if @guidances.count > 0 then%> +<% if @guidances.length > 0 then%>
<%= t("org_admin.guidance_group.name_label") %><%= t("org_admin.guidance.template") %><%= t("org_admin.guidance.published") %><%= t("org_admin.guidance_group.subset") %><%= t("org_admin.guidance.last_updated") %><%= t("org_admin.guidance.actions") %><%= t("org_admin.guidance_group.name_label") %><%= t("org_admin.guidance.published") %><%= t("org_admin.guidance_group.subset") %><%= t("org_admin.guidance.last_updated") %><%= t("org_admin.guidance.actions") %>
@@ -104,7 +103,7 @@ - <% if guidance.themes != [] then %> + <% if guidance.themes.present? then %>
<%= guidance.text.html_safe%> <% guidance.themes.each do |th| %> <%= th.title %>