Replace Kits with KitItems#5597
Conversation
| @storage_locations = current_organization.storage_locations.active | ||
| @items = current_organization.items.loose.active.alphabetized | ||
| @items = ConcreteItem.where(organization: current_organization).active.alphabetized | ||
| end |
There was a problem hiding this comment.
Add current_organization.concrete_items
|
|
||
| def index | ||
| @kits = current_organization.kits.includes(kit_item: {line_items: :item}).class_filter(filter_params) | ||
| @kits = current_organization.kit_items.includes(line_items: :item).class_filter(filter_params) |
There was a problem hiding this comment.
Note to self: consider renaming kit_items to kits, and therefore these diffs will look different and the semantics are lifted to the rename
There was a problem hiding this comment.
The main problem is having to rewrite the type for every entry in the items table that right now has KitItem. It doesn't save anything on the events migration (since we have to change the IDs from the kits table to the items table). I'm not too fussed about that, because it's easy to back out / fix if needed.
Claude estimates we'd save about 30 lines of churn by doing it all at once. I'm not really sure which way I'm leaning right now.
There was a problem hiding this comment.
@awwaiid I put in the commit to rename. IMO things look much smoother now.
Now that the standalone Kit model is gone and KitItem is the sole "kit"
concept, rename the STI subclass from KitItem to Kit to match the UI label,
the /kits routes, and the kit_item-free domain.
- app/models/kit_item.rb -> app/models/kit.rb (class KitItem -> Kit)
- Organization#kit_items association -> #kits
- Update all class refs, is_a? checks, the create service, events,
reports, views, seeds, factories and specs
- Migration flips the items.type discriminator 'KitItem' -> 'Kit'
- Drop two workarounds that were only needed while the class was KitItem:
- EventsHelper#eventable_path: with the class named Kit, polymorphic
routing resolves kit_path directly, so the event history row links
the eventable normally again
- the kit form's `url: kits_path, as: :kit` options: a new Kit now
infers kits_path and the :kit param key by default
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This is the semifinal step in the move to finally get rid of kits - in fact, that's what this PR does! The only thing left is a table and a column.
Previous PRs moved from a Kit having an item that had line items, to moving the line items directly to that item (now called a KitItem and part of an STI table).
This PR removes Kits entirely and changes all calling code to only look at the KitItems.
A couple of oddities:
Did some ad-hoc local testing and looks OK. Code was mostly generated by Claude and reviewed by me. Will definitely need some in-depth manual testing.