- added 2 not to be persisted attributes aimed at dealing with the UI
- added them to the permitted list
- updated view to switch mode about on_hand/on_demand
that is: from an already persisted variant or not
- Not persisted deals with on_*_desired not to be persisted fields
- Persisted mode deals with regular on_* fields
- the corresponding spec for both on_hand/on_demand
It turns out that the duplicator still raises an exception in some cases. Now I think I see why the the controller was catching the exceptions. At least now we know which exceptions to catch.
- Cop: Rails/RedundantActiveRecordAllMethod
- if receiver is an Active Record object, ".all" can be safely removed
- There are 2 allowed receivers that are listed in the
styleguide file (those are defaults cf. cop documentation).
Price is actually an association with lots of custom methods to make it look like a field, and so changes were ignored.
Now this issue is fixed, perhaps it should be moved to a concern..
Note, there are other delegated fields: product name and description may be assigned from the variant. But there's no hooks to save the prroduct, so I didn't include it when checking for changes.
These config values are relatively static but in some cases they can be called many times in the same request (like rendering a report or a large list of line_items in BOM). These values will now only get fetched from Redis/Postgres once at most per request/job.
We want to link variants/products to external DFC SuppliedProducts to
trigger supplier orders when local stock is exhausted. This is the first
step to enable the link.
This avoids unnecessary second message when left blank:
> can't be blank
> is not a number
Ok this is a little confusing. Why is there a separate presence check above, and why is it only for measurable units, when we still require a number for _all_ units? Because, for 'items', we allow a blank value then auto-set it to 1.
I don't know if it's really necessary, but that's how it currently works...
This can happen when there's a validation error. The field with error will also be marked changed, but the error style will override it.
I'd like to move this into a FormBuilder. Existing formbuilder gems don't seem to support it (though I didn't look very hard).
I guess validates_length_from_database also validates numbers. That's not a bad thing.
So now it's being validated, we should validate the transformed value that will be saved to the database.