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

Ticket #9869 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

[XPATCH] Fix observe call to not crash rails, when you use symbols

Reported by: queso Assigned to: core
Priority: high Milestone: 2.0
Component: ActiveRecord Version: edge
Severity: normal Keywords: observer
Cc:

Description

When using symbols for class names in an observe call (per the current edge rdocs), rails will fail to start properly. It complains about calling send on a symbol.

This is because array.flatten.collect! (line 134 in activerecord/lib/active_record/observer.rb) does not modify the models array and thus symbols get passed straight to the observed_classes call.

This patch just breaks the flatten out to it's own call, because flatten! doesn't chain well and will return nil if no changes are made.

Attachments

fix_observe_call_to_accept_symbols_and_not_crash_rails.diff (0.7 kB) - added by queso on 10/14/07 04:54:33.
The patch for fixing observer.rb to no longer crash rails when using symbols for class names

Change History

10/14/07 04:54:33 changed by queso

  • attachment fix_observe_call_to_accept_symbols_and_not_crash_rails.diff added.

The patch for fixing observer.rb to no longer crash rails when using symbols for class names

(in reply to: ↑ description ) 10/14/07 05:02:00 changed by queso

  • milestone changed from 2.x to 2.0.

Replying to queso:

When using symbols for class names in an observe call (per the current edge rdocs), rails will fail to start properly. It complains about calling send on a symbol. This is because array.flatten.collect! (line 134 in activerecord/lib/active_record/observer.rb) does not modify the models array and thus symbols get passed straight to the observed_classes call. This patch just breaks the flatten out to it's own call, because flatten! doesn't chain well and will return nil if no changes are made.

10/14/07 05:18:55 changed by nzkoz

  • summary changed from [PATCH] Fix observe call to not crash rails, when you use symbols to [XPATCH] Fix observe call to not crash rails, when you use symbols.

Could we have a test case for this please?

10/14/07 05:20:27 changed by rick

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

(In [7872]) Observers can observe model names as symbols properly now. Closes #9869 [queso]