From 73837b36bb152f4f51e969f5a7b997c8056f5092 Mon Sep 17 00:00:00 2001 From: Monica Cellio Date: Thu, 5 Dec 2024 17:19:19 -0500 Subject: [PATCH 1/3] when search turns up nothing, say so --- app/views/users/index.html.erb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index bfba7133e..cdc2d0829 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -22,10 +22,14 @@ role: 'button', 'aria-label': 'Sort by age' %> -
- <% @users.each do |user| %> - <%= render 'user', user: user %> - <% end %> -
+<% if @users.count == 0 %> +

No users found.

+<% else %> +
+ <% @users.each do |user| %> + <%= render 'user', user: user %> + <% end %> +
+<% end %> <%= will_paginate @users, renderer: BootstrapPagination::Rails %> From 97fdf5434ca918a9a0461ee1ab5b97f7b44f6fb9 Mon Sep 17 00:00:00 2001 From: Monica Cellio Date: Fri, 6 Dec 2024 10:44:46 -0500 Subject: [PATCH 2/3] use a strings file for i18n instead of baking in more English text --- app/views/users/index.html.erb | 2 +- config/locales/strings/en.search.yml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 config/locales/strings/en.search.yml diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index cdc2d0829..ce1aec7f7 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -23,7 +23,7 @@ <% if @users.count == 0 %> -

No users found.

+

<%= I18n.t('search.no_users') %> <% else %>

<% @users.each do |user| %> diff --git a/config/locales/strings/en.search.yml b/config/locales/strings/en.search.yml new file mode 100644 index 000000000..9358256b2 --- /dev/null +++ b/config/locales/strings/en.search.yml @@ -0,0 +1,5 @@ +en: + search: + # used on the users page (not the main search) + no_users: + No users found. From a8813eccb6667bede678903cc30741006b1b5000 Mon Sep 17 00:00:00 2001 From: Monica Cellio Date: Fri, 6 Dec 2024 11:06:46 -0500 Subject: [PATCH 3/3] close the p --- app/views/users/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index ce1aec7f7..f0ada48e5 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -23,7 +23,7 @@
<% if @users.count == 0 %> -

<%= I18n.t('search.no_users') %> +

<%= I18n.t('search.no_users') %>

<% else %>
<% @users.each do |user| %>