andypike / rectify

Build maintainable Rails apps
MIT License
596 stars 48 forks source link

Allow a Form to mimic a model with an attribute with the same name #44

Closed leio10 closed 6 years ago

leio10 commented 6 years ago

Currently, having a Form with an attribute with the same name of the mimicked model does not work well. In some cases, the value of the attribute is overwritten with the mimicked model data, resulting in invalid data.

With these changes, data from the mimicked model will override the params_hash hash values and the behavior will be the right one.

The only unsupported scenario is when the attribute contains a hash value, as it would be very difficult for the code to determine if the hash is the mimicked model information or the value for the attribute.

I modified tests to check this situation.

deivid-rodriguez commented 6 years ago

@andypike Friendly ping :)

deivid-rodriguez commented 6 years ago

@andypike We have rebased this branch as well, so it's easier for you to review it and potentially merge this. Thanks!