Skip to content

Commit

Permalink
fix: you shown to moderators (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
Waishnav authored Aug 5, 2024
1 parent 3bd69f1 commit 734f8a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/controllers/simple_discussion/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="user-avatar mr-2" ><img src="<%= gravatar_url_for(forum_post.user.email, size: 30) %>" alt="avatar of user" ></div>
<div class="details d-flex flex-column justify-content-between">
<p class="title"><%= 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 %>
</p>
<p class="subtitle"><%= t('on') %> &nbsp;<%= forum_post.created_at.strftime("%b %d, %Y") %></p>
</div>
Expand Down

0 comments on commit 734f8a4

Please sign in to comment.