From d14f4cc271bc313947bd2ff12338d85c18aba667 Mon Sep 17 00:00:00 2001 From: Vincent Rolea <3525369+virolea@users.noreply.github.com> Date: Thu, 12 Sep 2024 10:06:24 +0200 Subject: [PATCH] Use locale code as param --- app/controllers/rosetta/locales/translations_controller.rb | 2 +- app/models/rosetta/locale.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/rosetta/locales/translations_controller.rb b/app/controllers/rosetta/locales/translations_controller.rb index f085615..36b0ec5 100644 --- a/app/controllers/rosetta/locales/translations_controller.rb +++ b/app/controllers/rosetta/locales/translations_controller.rb @@ -13,7 +13,7 @@ def index private def set_locale - @locale = Locale.find(params[:locale_id]) + @locale = Locale.find_by!(code: params[:locale_id]) end end end diff --git a/app/models/rosetta/locale.rb b/app/models/rosetta/locale.rb index 836a8c7..6fc98e4 100644 --- a/app/models/rosetta/locale.rb +++ b/app/models/rosetta/locale.rb @@ -21,6 +21,10 @@ def default_locale end end + def to_param + code + end + def default_locale? @default ||= false end