blob: 55ec3bf4f11deaec1b539447b8f24390f27370df (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
module ActiveRecord::Associations::Builder
class HasAndBelongsToMany < CollectionAssociation #:nodoc:
def macro
:has_and_belongs_to_many
end
def valid_options
super + [:join_table, :association_foreign_key]
end
def define_callbacks(model, reflection)
super
name = self.name
model.send(:include, Module.new {
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def destroy_associations
association(:#{name}).delete_all
super
end
RUBY
})
end
end
end
|