2008年6月8日 星期日

association

use class methods( has_one, belongs_to, has_many,  has_and_belongs_to_many)
to create instance methods

has_one & belongs_to

has_many & belongs_to

has_and_belongs_to_many

the parameter for these methods:
:dependent => true
for delete.  
ex:
class Customer <>
         has_many  :orders,
                             :dependent=>true
end
if the customer A is deleted, its orders are also deleted

:order
ex:
:order=>"created_at ASC"
ascending order according to created_at field




沒有留言: