[Rails] ActiveRecord on data integrity

Jeremy Kemper jeremy at bitsweat.net
Fri Nov 19 20:23:13 GMT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Luis G. Gómez wrote:
| ...would AR errase a project's milestones if I errased the project that
| owns them?

has_many and has_one use the :dependent option to specify whether you
want associated objects to be destroyed along with the parent object.
The default is false.

class Project < ActiveRecord::Base
~  has_many :milestones, :dependent => true
end

will destroy associated milestones when the project is destroyed.  See
the has_many options at
http://ar.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#M000006
for more documentation.

Best,
jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBnlYwAQHALep9HFYRAo+8AJ9IWgirzgel01uUgzvLcwFPaAARkgCfXUol
2pzSWazC2E/LSsWO5CqLUTA=
=//Im
-----END PGP SIGNATURE-----


More information about the Rails mailing list