diff --git a/lib/rails_admin/adapters/active_record/association.rb b/lib/rails_admin/adapters/active_record/association.rb index 924afc1274..74e4076e48 100644 --- a/lib/rails_admin/adapters/active_record/association.rb +++ b/lib/rails_admin/adapters/active_record/association.rb @@ -39,7 +39,11 @@ def foreign_key def foreign_key_nullable? return if foreign_key.nil? || type != :has_many - klass.columns_hash[foreign_key.to_s].null + if klass.columns_hash[association.foreign_key.to_s] + klass.columns_hash[association.foreign_key.to_s].null + else + true + end end def foreign_type