Without Composition, persisted? works fine, but with Composition it gives this error apparently because it delegates to its model which is a Hash of multiple models.
Steps to reproduce
class MyForm < Reform::Form
include Composition
model :a
property :prop_1, on: :a
property :prop_2, on: :b
end
form = MyForm.new(a: OpenStruct.new, b: OpenStruct.new)
form.persisted? # undefined method `persisted?' for {:a=>#<OpenStruct>, :b=>#<OpenStruct>}:Hash
Using it in a form with form_for @form also generates the error, since form_for calls persisted?.
Workaround
An easy workaround is to simply add this to form class:
Without
Composition,persisted?works fine, but withCompositionit gives this error apparently because it delegates to itsmodelwhich is a Hash of multiple models.Steps to reproduce
Using it in a form with
form_for @formalso generates the error, sinceform_forcallspersisted?.Workaround
An easy workaround is to simply add this to form class: