diff options
author | Edward Faulkner <ef@alum.mit.edu> | 2011-02-04 15:34:44 -0500 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-02-04 19:39:59 -0200 |
commit | 909588d964bf27f20142a0b4d57890114a8d4a7a (patch) | |
tree | 13547fb5224456d7345ceb9a80ab1ed4dac2e8ff /activerecord/test/models | |
parent | df077604865b12b119be0259575675f45b958524 (diff) | |
download | rails-909588d964bf27f20142a0b4d57890114a8d4a7a.tar.gz rails-909588d964bf27f20142a0b4d57890114a8d4a7a.tar.bz2 rails-909588d964bf27f20142a0b4d57890114a8d4a7a.zip |
Fixing ordering of HABTM association deletion [#6191 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/lesson.rb | 11 | ||||
-rw-r--r-- | activerecord/test/models/student.rb | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/models/lesson.rb b/activerecord/test/models/lesson.rb new file mode 100644 index 0000000000..4c88153068 --- /dev/null +++ b/activerecord/test/models/lesson.rb @@ -0,0 +1,11 @@ +class LessonError < Exception +end + +class Lesson < ActiveRecord::Base + has_and_belongs_to_many :students + before_destroy :ensure_no_students + + def ensure_no_students + raise LessonError unless students.empty? + end +end diff --git a/activerecord/test/models/student.rb b/activerecord/test/models/student.rb new file mode 100644 index 0000000000..f459f2a9a3 --- /dev/null +++ b/activerecord/test/models/student.rb @@ -0,0 +1,3 @@ +class Student < ActiveRecord::Base + has_and_belongs_to_many :lessons +end |