using accepts_nested_attributes_for with reject_if and all_blank raises error
asanghi opened this issue · comments
Using this
accepts_nested_attribtues_for :addresses, allow_destroy: true, reject_if: :all_blank
raises ->
uninitialized constant ActiveRecord::MassAssignmentSecurity::NestedAttributes::ClassMethods::REJECT_ALL_BLANK_PROC
@asanghi it's because it is in a different lexical scope now ActiveRecord::NestedAttributes::ClassMethods
versus ActiveRecord::MassAssignmentSecurity::NestedAttributes::ClassMethods
. Can you come up with a PR to fix this? I think we just need to alias the constant in the correct lexical scope, e.g:
module ActiveRecord
module MassAssignmentSecurity
module NestedAttributes
module ClassMethods
REJECT_ALL_BLANK_PROC = ::ActiveRecord::NestedAttributes::ClassMethods::REJECT_ALL_BLANK_PROC
end
end
end
end
Is there failing test for this already? If not can you add one for :all_blank
option - thanks!
👍 also ran into this issue.
+1
+1
+1
Closed by #11