Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 show the follow button only to users allowed to follow #107

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/pages/users/show_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<% if current_user&.following?(user) %>
<%= button_to I18n.t("users.show_page.following"), user_unfollow_path(username), { method: :delete, data: { turbo: false }, class: "bg-blue-500 hover:bg-blue-600 text-center text-white font-bold py-2 px-4 rounded-full mt-4 block mx-auto" } %>
<% else %>
<% elsif allowed_to_follow? %>
<%= button_to I18n.t("users.show_page.follow"), user_follow_path(username), { data: { turbo: false }, class: "bg-blue-500 hover:bg-blue-600 text-center text-white font-bold py-2 px-4 rounded-full mt-4 block mx-auto" } %>
<% end %>
</div>
Expand Down
4 changes: 4 additions & 0 deletions app/pages/users/show_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@ def initialize(user:, current_user: nil)
def allowed_to_edit?
current_user.present? && allowed_to?(:edit?, user.profile, context: { user: current_user }, with: ProfilePolicy)
end

def allowed_to_follow?
current_user != user
end
end
end
Loading