Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #5535 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

[PATCH] Apply observers to subclasses created after observer is instantiated

Reported by: daniels@pronto.com.au Assigned to: David
Priority: normal Milestone: 1.2
Component: ActiveRecord Version: 1.1.1
Severity: normal Keywords: observer subclasses
Cc: bitsweat

Description

If a subclass of an ActiveRecord class is created after an observer has been attached to the parent class, the child class does not get observed.

The attached patch contains tests and fixes for this.

Attachments

apply_observers_to_new_subclasses.diff (1.6 kB) - added by daniels@pronto.com.au on 06/28/06 12:01:33.
Tests & Fix

Change History

06/28/06 12:01:33 changed by daniels@pronto.com.au

  • attachment apply_observers_to_new_subclasses.diff added.

Tests & Fix

06/28/06 12:29:49 changed by anonymous

  • version set to 1.1.1.

06/29/06 00:08:49 changed by daniels@pronto.com.au

By the way - the reason for the second test (test_observing_subclasses_with_lots_of_observers) was that my initial implementation was to alias and wrap the inherited method when an observer was added. The test is just evidence that that was a bad idea.

06/30/06 02:27:30 changed by bitsweat

  • cc set to bitsweat.
  • keywords set to observer subclasses.
  • milestone set to 1.2.

What is the evidence?

06/30/06 04:38:25 changed by bitsweat

  • status changed from new to closed.
  • resolution set to fixed.

(In [4521]) r4738@asus: jeremy | 2006-06-29 20:18:43 -0700

Observers also watch subclasses created after they are declared. Closes #5535.