hi people
I have something strange here, and I would like to share it with you,
to find a solution or at least, different opinion.
I have a rails 3.0.9 app. I’m trying to store historical data so I
made the following.
I have 3 tables “invoices”, “purchases”, “detail_purchases”. I’m using
“nested_attributes” (not nested form) in 2 levels deep (invoices
builds purchases and then purchases builds detail_purchases). Due to
this I have to use some callbacks, because I don’t have controllers
for “purchases” nor “detail_purchases”.
In the historical table I store
- user_id (user who made the change)
- object_id (in this case, the id of the invoice, id of purchase,
etc. depending on which one is changed or created) - class_name
- action_name (create, update, destroy, etc.)
- datetime
so, when I create an invoice, the logic order should be:
- create purchase
- create detail_purchase
- update purchase
- create invoice
but get the following, instead
- update purchase
- create detail_purchase
- create purchase
- create invoice
I check datetime, the order is correct, the registers are stored in
the database… but I still don’t understand how can I “update”
something that is not yet created.
Hope you can help me