-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.5.1 breaks simple_fields_for for custom form objects #1549
Comments
Probably because |
It seems we have a similar problem, if we have a wrapped model (presenter using StudyAssignmentPresenter.new(StudyAssignment.new).class # => StudyAssignmentPresenter
StudyAssignmentPresenter.new(StudyAssignment.new).to_model.class # => StudyAssignment You can hack around this as such: class StudyAssignmentPresenter < SimpleDelegator
def to_model; self; end
end |
The PR introducing the call to |
I can confirm that reverting the change from #1256 fixes the problem for me! |
@lacco does adding /cc @timurvafin |
Actually I am already providing |
You are right, now from version 3.5.1 we have to implement This information should be included in the releases notes, sorry about that 😥 . I will add some documentation about it. Thank you folks. |
@lacco just for curiosity. Does |
@felipegimenesptec You are correct, my class DryTypes::Model < Dry::Struct
include ActiveModel::Conversion
include ActiveModel::Validations
extend ActiveModel::Naming
# This is actually overwritten to def to_model; category; end in my case
def to_model
self
end
def persisted?
to_model == self ? false : to_model.persisted?
end
end |
I don't understand why this issue is closed, can you provide any context? Apps that break in a patch-level upgrade from 3.5.0 to 3.5.1 seems like it must be a bug? I would consider it a bug for patch-level release to ever include breaking changes... |
I consider it a bug fix since Simple Form should work as a Rails Form like |
I guess it isn't a breaking change since it doesn't break any features described in the README. The fact it supported non-ActiveModel compliant objects was an unintentional feature and strictly speaking a bug since that meant it did not have parity with It is just a bit unfortunate. |
We previously supported `~> 3.2`. The regression introduced in v3.5.1 is described at heartcombo/simple_form#1549. We'll need to fix our presenters to be `ActiveModel` compliant to make `simple_form` work correctly past that version. In the meanwhile, we shouldn't require any simple_form upgrade as part of an upcoming Hyrax release.
We previously supported `~> 3.2`. The regression introduced in v3.5.1 is described at heartcombo/simple_form#1549. We'll need to fix our presenters to be `ActiveModel` compliant to make `simple_form` work correctly past that version. In the meanwhile, we shouldn't require any simple_form upgrade as part of an upcoming Hyrax release.
Beginning with `v3.5.1`, Simple Form now requires models passed to it to conform to the `ActiveModel` interface; particularly, they must implement `#to_model`. We will restrict to `<= 3.5.0` to prevent unexpected breakage for downstream apps. Support for `v3.5.1` and up should be readded (this may just require testing/documentation fixes) and a major version released to get us back to tracking current `simple_form` development. See also: samvera/hyrax#2758 and heartcombo/simple_form#1549.
Beginning with `v3.5.1`, Simple Form now requires models passed to it to conform to the `ActiveModel` interface; particularly, they must implement `#to_model`. We will restrict to `<= 3.5.0` to prevent unexpected breakage for downstream apps. Support for `v3.5.1` and up should be readded (this may just require testing/documentation fixes) and a major version released to get us back to tracking current `simple_form` development. See also: samvera/hyrax#2758 and heartcombo/simple_form#1549.
Environment
Current/ expected behavior
Prior to 3.5.1, I was able to build my own form objects using http://dry-rb.org/gems/dry-types/ . It is looking something like
and
After the update,
name_fields.object
returnsnil
and breaks my code. Does somebody have a hint which change could have caused the issue?The text was updated successfully, but these errors were encountered: