Search the web
Sign In
New User? Sign Up
rails_artist · Only Ruby on Rails Artist here
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
good of active record :dependent   Message List  
Reply | Forward Message #10 of 23 |
i was refactoring our Item model, where we have 3 has_many with 3 mapping
models.
as we are not using InnoDB based foreign key constraint, we were searching
some sort of reliable solution,
which will take pressure in application layer instead of leaving it to the
database.

so later we introduced ":dependent" with has_may relation. here is our top
of Item model.
has_many :category_mappings, :dependent => :destroy
has_many :categories, :through => :category_mappings

has_many :property_values, :dependent => :destroy
has_many :properties, :through => :property_value

has_many :item_location_mappings, :dependent => :destroy
has_many :locations, :through => :item_location_mappings

our "dependent" flagship is destroying all related items in the item destroy
process which has introduced
our flexibility and reduced a lot of code to manage such stuff in a DRY(ied)
manner.

so the following unit test worked fine for us.

some bad side,
dependent delete each and every item one by one, which is big issue when you
have a big chunk of dependent data.
but that is not suppose to be common in every context. we have no problem
with this issue.

best of luck!

--
----------------------------------------------------
nhm tanveer hossain khan (hasan)
http://hasan.we4tech.com
----------------------------------------------------
mobile: +880 1713 090 511
----------------------------------------------------
"work for fun"


[Non-text portions of this message have been removed]




Sat Oct 27, 2007 10:36 am

hasan83bd
Offline Offline
Send Email Send Email

Forward
Message #10 of 23 |
Expand Messages Author Sort by Date

i was refactoring our Item model, where we have 3 has_many with 3 mapping models. as we are not using InnoDB based foreign key constraint, we were searching ...
nhm tanveer hossain k...
hasan83bd
Offline Send Email
Oct 27, 2007
10:36 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help