I have this model called InventoryItem. Every time an InventoryItem is
created (through the CharactersController and the create_item action) I
need to update others tables and make lookups in other tables, to check
if the Character has the prerequisites to actually create the
My problem is that I cannot seem to find a good place to put this logic.
I’ve tried to put it in a InventoryItem#validate_on_create. This is a
hassle, because the InventoryItem has no direct association to all the
things it need to check/update. Also, isn’t it against the guide lines
that validations actually updates/changes stuff as it is required here?
I’ve also tried placing most of the logic in the create_item action
itself, however this also results in rather ugly code I think (see
attached). This also has the drawback that InventoryItem validation
errors and “prerequisite errors” are shown in different ways in the
views, because they are stored in @inventory_item.errors and
There must be a better way?
Where do you guys put logic like this? Any ideas/suggestions are very
Thanks in advance.