aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/lesson.rb
diff options
context:
space:
mode:
authorEdward Faulkner <ef@alum.mit.edu>2011-02-04 15:34:44 -0500
committerSantiago Pastorino <santiago@wyeworks.com>2011-02-04 19:39:59 -0200
commit909588d964bf27f20142a0b4d57890114a8d4a7a (patch)
tree13547fb5224456d7345ceb9a80ab1ed4dac2e8ff /activerecord/test/models/lesson.rb
parentdf077604865b12b119be0259575675f45b958524 (diff)
downloadrails-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/lesson.rb')
-rw-r--r--activerecord/test/models/lesson.rb11
1 files changed, 11 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