From 734f8a44cbe7bfda337b1fa9583daeef950ce252 Mon Sep 17 00:00:00 2001 From: Vaishnav Deore <86405648+Waishnav@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:39:27 +0530 Subject: [PATCH] fix: you shown to moderators (#31) --- app/controllers/simple_discussion/application_controller.rb | 5 +++++ app/views/simple_discussion/forum_posts/_forum_post.html.erb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/simple_discussion/application_controller.rb b/app/controllers/simple_discussion/application_controller.rb index d9587fd..e464f26 100644 --- a/app/controllers/simple_discussion/application_controller.rb +++ b/app/controllers/simple_discussion/application_controller.rb @@ -12,6 +12,11 @@ def is_moderator_or_owner?(object) end helper_method :is_moderator_or_owner? + def is_owner?(object) + object.user == current_user + end + helper_method :is_owner? + def is_moderator? current_user.respond_to?(:moderator?) && current_user.moderator? end diff --git a/app/views/simple_discussion/forum_posts/_forum_post.html.erb b/app/views/simple_discussion/forum_posts/_forum_post.html.erb index 79688d7..9f2964f 100644 --- a/app/views/simple_discussion/forum_posts/_forum_post.html.erb +++ b/app/views/simple_discussion/forum_posts/_forum_post.html.erb @@ -19,7 +19,7 @@
avatar of user

<%= forum_post.user.name %> <%= forum_user_badge(forum_post.user) %> - <% if is_moderator_or_owner?(forum_post) %>(You)<% end %> + <% if is_owner?(forum_post) %>(You)<% end %>

<%= t('on') %>  <%= forum_post.created_at.strftime("%b %d, %Y") %>