Closed sbeam closed 8 years ago
Yes, I have the same scenario, and would like to see this code merged please
This is very useful - I've been using this pull request on an app in development (hoping it get's merged). I'm not sure if this is the right place to ask this (seemed too specific for stack overflow) but when I push to Heroku, it reverts back to using a PUT method when I try BIP for creating a new record. It works fine on local machine, it just does this on Heroku.
If you have any ideas or could push me in the right direction to figure it out, I would appreciate it.
This use case is maybe a little unusual, but I hope the tests that are added around "TestResult" make it clear. We have a situation where a main model has a bunch of value associations that have to be filled out (and in reality the exact set of the values needed is dependent on a number of factors, and we can't pre-build a bunch of nil values). The schema is a basic EAV setup, but as in the tests, it could work with something de-normalized.
So the controller instantiates new, unsaved objects for the values - with the correct id's needed to build the associations - and passes each one to the
best_in_place
helper. When the field is submitted it's sent as a POST which creates the new value, and then the field is changed to be a "normal" BIP field that then does an update. So the values can be created lazily and only as-needed.All one has to do then is pass an object that responds true for
new_record?
and the REST interaction should be adjusted accordingly.