From 5560167aa35e049eaf76e3fd342a27d3a3413c88 Mon Sep 17 00:00:00 2001 From: TheNeedful-DO Date: Thu, 23 Nov 2023 14:49:46 +0000 Subject: [PATCH] Anon user name --- app/models/user.rb | 2 +- app/policies/user_policy.rb | 4 +++- app/views/users/home.html.haml | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 7e63ebd5..0860e07d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -82,7 +82,7 @@ class User < ActiveRecord::Base end def display_name - self.email.split("@")[0] || "Guest#{self.soft_token[0..5]}" + principal[0..4] end def sit_in(seat) diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb index 0b8d7ba5..e75d57e7 100644 --- a/app/policies/user_policy.rb +++ b/app/policies/user_policy.rb @@ -16,7 +16,9 @@ class UserPolicy if user.admin? scope.all else - scope.where(role: User.roles[:admin]) + scope.all + # scope.where(role: User.roles[:admin]) + # scope.all.where(id: @user.id) end end diff --git a/app/views/users/home.html.haml b/app/views/users/home.html.haml index d9d261b9..42642c9b 100644 --- a/app/views/users/home.html.haml +++ b/app/views/users/home.html.haml @@ -7,6 +7,11 @@ %section.stats = render 'shared/stats' +- if @feed_items.any? + .contain + %h2 Post feed + = render 'shared/feed' + - if @user.microposts.any? %section.microposts %h2 My Posts #{@user.microposts.count} @@ -14,7 +19,3 @@ = render @microposts = will_paginate @microposts -- if @feed_items.any? - .contain - %h2 Post feed - = render 'shared/feed'