Replies: 1 comment 3 replies
-
|
This is a strange pattern. ActiveModels effect Models, so why wouldn't you just do: Maybe the premise that you need to set every field is the missing piece of information? You don't need to set every field... The above code block is an example of that but this is also similar: There's no reason you'd need to be explicitly setting Unchanged on every field. If you're receiving incoming data from JSON and the above is just a simplified example of your problem, you can similarly automatically convert JSON or structs into ActiveModels with everything automatically set. Various docs discuss this:
Basically the concept of modifying a Model to turn it into an ActiveModel which in turn just generates another Model seems incorrect. You should not be modifying Models, only ActiveModels. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to request an approval for creating
active_model_from_diffmethod that will generate active model based on difference between old and new model for update operation.If similar functionality already exist, please let me know.
This method will simplify update operation (remove boilerplate) if you preserve original model while mutating it's clone or getting
book_newfrom other sources.Example of what you currently need to do to get active model:
Beta Was this translation helpful? Give feedback.
All reactions