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:

1. create purchase
2. create detail_purchase
3. update purchase
4. create invoice

but get the following, instead

1. update purchase
2. create detail_purchase
3. create purchase
4. 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

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 28, '11 at 9:31p
activeNov 28, '11 at 9:31p
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Angelo Cordova: 1 post

People

Translate

site design / logo © 2022 Grokbase