Skip to content

Commit e54ac8e

Browse files
committed
Fix sorting on profile page
1 parent ff921c0 commit e54ac8e

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

app/helpers/application_helper.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,21 @@ def community_user_url(user)
386386
end
387387
end
388388

389+
# Helper for community user path with query params (for sorting/filtering links)
390+
# On community domain in production, uses /:id. Otherwise uses /community/:id.
391+
def community_user_path(user, params = {})
392+
base_path = if Rails.env.production? && request.host == Rails.application.config.x.domains.community
393+
"/#{user.to_param}"
394+
else
395+
user_path(user)
396+
end
397+
398+
return base_path if params.blank?
399+
400+
query = params.compact.to_query
401+
query.present? ? "#{base_path}?#{query}" : base_path
402+
end
403+
389404
# URL for community map data endpoint (works across domains)
390405
def community_map_data_url
391406
if Rails.env.production? && request.host == Rails.application.config.x.domains.community

app/views/users/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
next_dir = (key == "az") ? "asc" : "desc"
293293
end
294294
%>
295-
<%= link_to menu_label, user_path(@user, project_sort: key, project_dir: next_dir),
295+
<%= link_to menu_label, community_user_path(@user, project_sort: key, project_dir: next_dir),
296296
class: "block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:bg-gray-100 focus:text-gray-900 focus:outline-none cursor-pointer" %>
297297
<% end %>
298298
</div>

0 commit comments

Comments
 (0)