From b5612eddda25be03feefde40ccecabb7eda4a15f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Wed, 17 Oct 2018 16:53:55 -0500 Subject: [PATCH] safety around empty content --- app/views/layouts/_sidenav.html.erb | 2 +- app/views/main/dashboard.html.erb | 2 +- app/views/universes/_picker.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/_sidenav.html.erb b/app/views/layouts/_sidenav.html.erb index 31ada4c6..6bcacc8a 100644 --- a/app/views/layouts/_sidenav.html.erb +++ b/app/views/layouts/_sidenav.html.erb @@ -93,7 +93,7 @@ @universe_scope.send(pluralized_name).count else ( - @current_user_content[content_type] + + @current_user_content[content_type] || [] + current_user.send("contributable_#{pluralized_name}") + (content_type_klass == Universe ? [] : content_type_klass.where(universe_id: current_user.universes.pluck(:id))) ).uniq.count diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index 929b9983..019366c5 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -21,7 +21,7 @@ if @universe_scope.present? && content_type != 'Universe' content_list = @universe_scope.send(pluralized_content_name) else - content_list = @current_user_content[content_type] + + content_list = @current_user_content[content_type] || [] + current_user.send("contributable_#{pluralized_content_name}") # todo I don't think this is actually necessary anymore, but leaving around for a few days just in case diff --git a/app/views/universes/_picker.html.erb b/app/views/universes/_picker.html.erb index b4040db4..a3e9e456 100644 --- a/app/views/universes/_picker.html.erb +++ b/app/views/universes/_picker.html.erb @@ -20,7 +20,7 @@
  • <%= link_to "All universes", "?universe=all" %>
  • <% if current_user %>
  • - <% (@current_user_content['Universe'] + current_user.contributable_universes).sort_by(&:name).each do |universe| %> + <% ((@current_user_content['Universe'] || []) + current_user.contributable_universes).sort_by(&:name).each do |universe| %>
  • <%= link_to universe.name + (universe.user_id == current_user.id ? '' : ' (contributor)'), "?universe=#{universe.id}" %>
  • <% end %> <% end %>