TrestleAdmin / trestle

A modern, responsive admin framework for Ruby on Rails
https://trestle.io
GNU Lesser General Public License v3.0
1.96k stars 177 forks source link

When enum defined in Rails6 model with Int8 and mapper in model like: #453

Closed trumenov closed 1 year ago

trumenov commented 1 year ago

When enum defined in Rails6 model with Int8 and mapper in model like: enum kind: { manual: 0, automated: 1, mixed: 2 }, _prefix: true

In this case, the default edit form loses model current value.

CLAassistant commented 1 year ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

spohlenz commented 1 year ago

This does indeed appear to be backwards in its current form. I'm not sure how it ended up that way, although I suspect it is due to my own over-reliance on string-backed enums.

I've fixed this in 55963f5 -- the fix was part of what you had -- to simply to use the enum key/label instead of the value/index as the checkbox value. The other changes within the form builder I don't believe are necessary though.

Could you confirm this solves the issue for you?