diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 049e1a0b..f253b13b 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -22,6 +22,8 @@ class MainController < ApplicationController def dashboard return redirect_to new_user_session_path unless user_signed_in? + @content_types = current_user.user_content_type_activators.pluck(:content_type) + ask_question end diff --git a/app/views/main/dashboard.html.erb b/app/views/main/dashboard.html.erb index 58f7387e..0f35dcb3 100644 --- a/app/views/main/dashboard.html.erb +++ b/app/views/main/dashboard.html.erb @@ -26,24 +26,23 @@ %>
- <% [:universe, :character, :location, :item, :creature, :race, :religion, :group, :magic, :language, :flora, :scene].each do |type| %> + <% @content_types.reverse.each do |content_type| %> <% - pluralized_content_name = type.to_s.pluralize + pluralized_content_name = content_type.downcase.pluralize - if @universe_scope.present? && type != :universe + if @universe_scope.present? && content_type != 'Universe' content_list = @universe_scope.send(pluralized_content_name) else content_list = current_user.send(pluralized_content_name) + current_user.send("contributable_#{pluralized_content_name}") - unless type == :universe + unless content_type == 'Universe' content_list.concat(current_user.universes.flat_map { |universe| universe.send(pluralized_content_name) }).uniq! end end %> - <% next if !current_user.can_create?(type.to_s.capitalize.constantize) && content_list.empty? %>
"> - <%= render partial: 'content/cards/in_universe_content_list', locals: { content_type: type, content_list: content_list } %> + <%= render partial: 'content/cards/in_universe_content_list', locals: { content_type: content_type.downcase, content_list: content_list } %>
<% end %>