Use partial for rule translation loop during registration

This commit is contained in:
Matt Jankowski 2025-08-27 11:31:54 -04:00
parent b6cd32281f
commit e6a6a74882
3 changed files with 9 additions and 7 deletions

View File

@ -135,7 +135,10 @@ class Auth::RegistrationsController < Devise::RegistrationsController
@accept_token = session[:accept_token] = SecureRandom.hex
@invite_code = invite_code
set_locale { render :rules }
set_locale do
@rule_translations = @rules.map { |rule| rule.translation_for(I18n.locale) }
render :rules
end
end
def is_flashing_format? # rubocop:disable Naming/PredicatePrefix

View File

@ -17,12 +17,7 @@
%p.lead= t('auth.rules.preamble', domain: site_hostname)
%ol.rules-list
- @rules.each do |rule|
- translation = rule.translation_for(I18n.locale.to_s)
%li
%button{ type: 'button', aria: { expanded: 'false' } }
.rules-list__text= translation.text
.rules-list__hint= translation.hint
= render @rule_translations
.stacked-actions
- accept_path = @invite_code.present? ? public_invite_url(invite_code: @invite_code, accept: @accept_token) : new_user_registration_path(accept: @accept_token)

View File

@ -0,0 +1,4 @@
%li
%button{ type: 'button', aria: { expanded: 'false' } }
.rules-list__text= rule_translation.text
.rules-list__hint= rule_translation.hint