From 1e7893695ae868f095a1e6f7db460a09080ba5eb Mon Sep 17 00:00:00 2001 From: Xero Date: Wed, 6 Mar 2024 14:35:21 -0500 Subject: [PATCH] allow show to be via name for genera and families as well --- app/controllers/families_controller.rb | 3 ++- app/controllers/genera_controller.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/families_controller.rb b/app/controllers/families_controller.rb index f26e12e..7f9ac82 100644 --- a/app/controllers/families_controller.rb +++ b/app/controllers/families_controller.rb @@ -61,7 +61,8 @@ def destroy private # Use callbacks to share common setup or constraints between actions. def set_family - @family = Family.find(params[:id]) + @family = Family.find_by(name: params[:id]) + @family ||= Family.find(params[:id]) end # Only allow a list of trusted parameters through. diff --git a/app/controllers/genera_controller.rb b/app/controllers/genera_controller.rb index 970df86..3aef29d 100644 --- a/app/controllers/genera_controller.rb +++ b/app/controllers/genera_controller.rb @@ -61,7 +61,8 @@ def destroy private # Use callbacks to share common setup or constraints between actions. def set_genus - @genus = Genus.find(params[:id]) + @genus = Genus.find_by(name: params[:id]) + @genus ||= Genus.find(params[:id]) end # Only allow a list of trusted parameters through.