Mislav Marohnić
2010-Apr-16 18:00 UTC
Active Record observers broken: can''t be used for "before" callbacks
I was just wondering what about a report that I made almost 2 months ago: Active Record observers broken<https://rails.lighthouseapp.com/projects/8994/tickets/4087-activerecord-observers-cant-be-used-for-before-callbacks> I think it''s a pretty big bug. In Rails 3, creating an observer with a "before_save" callback (for instance) will result in all observed models being *unable to save*, unconditionally. This is because the key method (`notify_observers`) of "Observable" module from Ruby (in use here) is always returning false, without giving us access to the return value of callback methods. The only way of fixing it is to stop using the Ruby implementation which doesn''t give us access to return values of callback methods. I''ve attached my proposed fix to the ticket. I''ve decoupled from Observable Ruby module since we haven''t been using most of its code anyway. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Jeremy Kemper
2010-Apr-16 20:40 UTC
Re: Active Record observers broken: can''t be used for "before" callbacks
On Fri, Apr 16, 2010 at 11:00 AM, Mislav Marohnić <mislav.marohnic@gmail.com> wrote:> I was just wondering what about a report that I made almost 2 months ago: > Active Record observers broken > I think it''s a pretty big bug. In Rails 3, creating an observer with a > "before_save" callback (for instance) will result in all observed models > being unable to save, unconditionally. > This is because the key method (`notify_observers`) of "Observable" module > from Ruby (in use here) is always returning false, without giving us access > to the return value of callback methods. The only way of fixing it is to > stop using the Ruby implementation which doesn''t give us access to return > values of callback methods. > I''ve attached my proposed fix to the ticket. I''ve decoupled from Observable > Ruby module since we haven''t been using most of its code anyway.Nasty one. Your fix looks great. Thanks Mislav! jeremy -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Maybe Matching Threads
- when will "TODO" comment/rake support come out?
- Should an blank string be html_safe?
- Polymorphic URL helpers documentation and fixes
- In development mode not all types are included in the query related to type
- ActionView 2.0.2 broken without ActionController