Hi there,

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
InventoryItem.

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
flash[:error] respectively.

There must be a better way?
Where do you guys put logic like this? Any ideas/suggestions are very
welcome.

Thanks in advance.

- Rasmus

Attachments:
http://www.ruby-forum.com/attachment/2949/test.txt

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to