Replies: 1 comment 2 replies
-
Hi @stex! I am glad this gem helps you as much as it helped me :) That is an interesting approach! Having them act as form models directly sounds like a really good feature, as they often sit as proxies to form actions. If this doesn’t add constraints or too strong tradeoffs, this is definitely something that could fit inside the rails extension. I’d be happy to help review and maintain this feature if you’d like to try a PR on actor-rails \o/ |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey @sunny!
First of all, thanks a lot for this gem, it makes structuring a lot of operations in my applications a lot easier and testable :)
In an application I'm currently working on, I'm using actors quite often as direct recipients of form parameters, meaning the form fields map directly to
input
s on the actor.Until today, I was usually passing in an instance of the model that the actor would create to the form and map its attributes to the actor inputs (and errors back to the record), but this got my controllers a bit messy over time.
What I did now is a bit of monkey patching to make actors valid objects to be used in forms, including
ActiveModel::Naming
and errors support, so the following is possible:I had to create an individual result class per actor dynamically as I needed to control its name for
i18n
and make sure to pass down errors fromCheckable
intoActiveModel::Errors
.Do you think this would be a feature that's worth implementing properly, e.g. in the rails extension for this gem (or a new one)?
Beta Was this translation helpful? Give feedback.
All reactions