Skip to content

Commit 334c844

Browse files
committed
Filter only models that actually translate.
Devise's Session does not translate, which led to an error in the original implementation.
1 parent 5398c5a commit 334c844

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/active_admin/globalize3/filter_empty_translations.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ module FilterEmptyTranslations
3232
# This filter removes all empty and unsaved translations from params
3333
# and marks empty and saved translation for deletion.
3434
def filter_empty_translations
35-
model = controller_name.singularize.to_sym
35+
model_class = controller_name.classify.safe_constantize
36+
if model_class.nil? or not model_class.translates?
37+
return
38+
end
39+
model = controller_name.singularize.to_sym
3640
params[model][:translations_attributes].each do |t|
3741
if !(t.last.map { |_, v| v.empty? ? true : false }[2..-1]).include?(false)
3842
if t.last[:id].empty?

0 commit comments

Comments
 (0)