From 06d2d49036400e4a9d82dbef3bb58c7094b4114a Mon Sep 17 00:00:00 2001 From: Sead Feng Date: Sat, 24 Jun 2023 17:49:11 +0800 Subject: [PATCH 1/4] Fixed params. eg. params[:blog_post] => params[:post] Fixed params When ActiveAdmin.register Blog::Post, the params will be params[:blog_post], it need to change to params[:post] --- lib/activeadmin_addons/support/input_helpers/input_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/activeadmin_addons/support/input_helpers/input_methods.rb b/lib/activeadmin_addons/support/input_helpers/input_methods.rb index d99694e2..50ba2d1c 100644 --- a/lib/activeadmin_addons/support/input_helpers/input_methods.rb +++ b/lib/activeadmin_addons/support/input_helpers/input_methods.rb @@ -1,7 +1,7 @@ module ActiveAdminAddons module InputMethods def model_name - valid_object.class.to_s.underscore.tr('/', '_') + builder.options[:as] end def valid_method From 05545befaf976f4935eb1de293cd14279fde35b7 Mon Sep 17 00:00:00 2001 From: Sead Feng Date: Sat, 24 Jun 2023 18:25:05 +0800 Subject: [PATCH 2/4] Update input_methods.rb --- .../support/input_helpers/input_methods.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/activeadmin_addons/support/input_helpers/input_methods.rb b/lib/activeadmin_addons/support/input_helpers/input_methods.rb index 50ba2d1c..428ba5c0 100644 --- a/lib/activeadmin_addons/support/input_helpers/input_methods.rb +++ b/lib/activeadmin_addons/support/input_helpers/input_methods.rb @@ -1,7 +1,11 @@ module ActiveAdminAddons module InputMethods def model_name - builder.options[:as] + if builder.options[:as] + builder.options[:as] + else + valid_object.class.to_s.underscore.tr('/', '_') + end end def valid_method From 12768c5ba3d981ac7fa1c634a6d4b3ebf41205cf Mon Sep 17 00:00:00 2001 From: Sead Feng Date: Sat, 24 Jun 2023 18:38:31 +0800 Subject: [PATCH 3/4] Update input_methods.rb --- lib/activeadmin_addons/support/input_helpers/input_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/activeadmin_addons/support/input_helpers/input_methods.rb b/lib/activeadmin_addons/support/input_helpers/input_methods.rb index 428ba5c0..9d672c1e 100644 --- a/lib/activeadmin_addons/support/input_helpers/input_methods.rb +++ b/lib/activeadmin_addons/support/input_helpers/input_methods.rb @@ -1,7 +1,7 @@ module ActiveAdminAddons module InputMethods def model_name - if builder.options[:as] + if builder.options[:as].present? builder.options[:as] else valid_object.class.to_s.underscore.tr('/', '_') From b2fc259c5e8e6ff5b4c620ca5c45bad1e6f0080a Mon Sep 17 00:00:00 2001 From: Sead Feng Date: Sat, 24 Jun 2023 23:11:38 +0800 Subject: [PATCH 4/4] Update input_methods.rb --- lib/activeadmin_addons/support/input_helpers/input_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/activeadmin_addons/support/input_helpers/input_methods.rb b/lib/activeadmin_addons/support/input_helpers/input_methods.rb index 9d672c1e..0b12655e 100644 --- a/lib/activeadmin_addons/support/input_helpers/input_methods.rb +++ b/lib/activeadmin_addons/support/input_helpers/input_methods.rb @@ -1,7 +1,7 @@ module ActiveAdminAddons module InputMethods def model_name - if builder.options[:as].present? + if respond_to?(:builder) && builder.options[:as].present? builder.options[:as] else valid_object.class.to_s.underscore.tr('/', '_')