<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer">1366</assigned-user-id>
  <attachments-count type="integer">2</attachments-count>
  <closed type="boolean">false</closed>
  <created-at type="datetime">2008-12-26T21:58:41+00:00</created-at>
  <creator-id type="integer">41923</creator-id>
  <milestone-due-on type="datetime" nil="true"></milestone-due-on>
  <milestone-id type="integer">27004</milestone-id>
  <number type="integer">1639</number>
  <permalink>adds-an-on-option-to-activerecord-observers</permalink>
  <priority type="integer">976</priority>
  <project-id type="integer">8994</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>open</state>
  <tag>activerecord observers patch</tag>
  <title>Adds an :on option to ActiveRecord observers</title>
  <updated-at type="datetime">2010-01-20T11:11:21+00:00</updated-at>
  <user-id type="integer">65556</user-id>
  <user-name>Rizwan Reza</user-name>
  <creator-name>Gabriel Gironda</creator-name>
  <assigned-user-name>Pratik</assigned-user-name>
  <url>http://rails.lighthouseapp.com/projects/8994/tickets/1639</url>
  <milestone-title>3.0</milestone-title>
  <original-body>I needed to use an observer to observe multiple models, but only wanted to observe certain sets of changes on each one. There was also a bug where calling `observe` twice in an ActiveRecord Observer would clear out any previous list of observed classes. This patch adds both the :on option and refactors the workings of the `observe` method to not clear out models from previous declarations</original-body>
  <latest-body>I needed to use an observer to observe multiple models, but only wanted to observe certain sets of changes on each one. There was also a bug where calling `observe` twice in an ActiveRecord Observer would clear out any previous list of observed classes. This patch adds both the :on option and refactors the workings of the `observe` method to not clear out models from previous declarations</latest-body>
  <original-body-html>&lt;div&gt;&lt;p&gt;I needed to use an observer to observe multiple models, but only
wanted to observe certain sets of changes on each one. There was
also a bug where calling &lt;code&gt;observe&lt;/code&gt; twice in an
ActiveRecord Observer would clear out any previous list of observed
classes. This patch adds both the :on option and refactors the
workings of the &lt;code&gt;observe&lt;/code&gt; method to not clear out models
from previous declarations&lt;/p&gt;&lt;/div&gt;</original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I needed to use an observer to observe multiple models, but only wanted to observe certain sets of changes on each one. There was also a bug where calling `observe` twice in an ActiveRecord Observer would clear out any previous list of observed classes. This patch adds both the :on option and refactors the workings of the `observe` method to not clear out models from previous declarations</body>
      <body-html>&lt;div&gt;&lt;p&gt;I needed to use an observer to observe multiple models, but only
wanted to observe certain sets of changes on each one. There was
also a bug where calling &lt;code&gt;observe&lt;/code&gt; twice in an
ActiveRecord Observer would clear out any previous list of observed
classes. This patch adds both the :on option and refactors the
workings of the &lt;code&gt;observe&lt;/code&gt; method to not clear out models
from previous declarations&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-12-26T21:58:41+00:00</created-at>
      <creator-id type="integer">41923</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1639</number>
      <permalink>adds-an-on-option-to-activerecord-observers</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>patch</tag>
      <title>Adds an :on option to ActiveRecord observers</title>
      <updated-at type="datetime">2008-12-26T21:58:47+00:00</updated-at>
      <user-id type="integer">41923</user-id>
      <user-name>Gabriel Gironda</user-name>
      <creator-name>Gabriel Gironda</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1639</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>The would read much better if you could do:

observe :comment, :photo, :after =&gt; :create

-or-

observe :comment, :photo, :on =&gt; [:create, :update]</body>
      <body-html>&lt;div&gt;&lt;p&gt;The would read much better if you could do:&lt;/p&gt;
&lt;p&gt;observe :comment, :photo, :after =&amp;gt; :create&lt;/p&gt;
&lt;p&gt;-or-&lt;/p&gt;
&lt;p&gt;observe :comment, :photo, :on =&amp;gt; [:create, :update]&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-12-27T01:12:13+00:00</created-at>
      <creator-id type="integer">41923</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1639</number>
      <permalink>adds-an-on-option-to-activerecord-observers</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>patch</tag>
      <title>Adds an :on option to ActiveRecord observers</title>
      <updated-at type="datetime">2008-12-27T01:12:17+00:00</updated-at>
      <user-id type="integer">5443</user-id>
      <user-name>Bryan Liles</user-name>
      <creator-name>Gabriel Gironda</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1639</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Thanks for the comments, Bryan!

The former, I agree with. When I get a moment I'll add that functionality to the patch.

The latter would be a problem because there's cases where you might want `before_update` rather than `after_update`. Defaulting it to use `after_` by convention would cause problems in the case where a custom callback is being used - `notify(:before_some_domain_specific_event)` in your models, for example.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Thanks for the comments, Bryan!&lt;/p&gt;
&lt;p&gt;The former, I agree with. When I get a moment I'll add that
functionality to the patch.&lt;/p&gt;
&lt;p&gt;The latter would be a problem because there's cases where you
might want &lt;code&gt;before_update&lt;/code&gt; rather than
&lt;code&gt;after_update&lt;/code&gt;. Defaulting it to use &lt;code&gt;after_&lt;/code&gt;
by convention would cause problems in the case where a custom
callback is being used -
&lt;code&gt;notify(:before_some_domain_specific_event)&lt;/code&gt; in your
models, for example.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-12-27T01:24:53+00:00</created-at>
      <creator-id type="integer">41923</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1639</number>
      <permalink>adds-an-on-option-to-activerecord-observers</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>patch</tag>
      <title>Adds an :on option to ActiveRecord observers</title>
      <updated-at type="datetime">2008-12-27T01:24:55+00:00</updated-at>
      <user-id type="integer">41923</user-id>
      <user-name>Gabriel Gironda</user-name>
      <creator-name>Gabriel Gironda</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1639</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Here's a new patch that adds the :after =&gt; :create kind of syntax.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Here's a new patch that adds the :after =&amp;gt; :create kind of
syntax.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-01-27T22:45:14+00:00</created-at>
      <creator-id type="integer">41923</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1639</number>
      <permalink>adds-an-on-option-to-activerecord-observers</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>patch</tag>
      <title>Adds an :on option to ActiveRecord observers</title>
      <updated-at type="datetime">2009-01-27T22:45:19+00:00</updated-at>
      <user-id type="integer">41923</user-id>
      <user-name>Gabriel Gironda</user-name>
      <creator-name>Gabriel Gironda</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1639</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-08-04T18:14:05+01:00</created-at>
      <creator-id type="integer">41923</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: patch
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1639</number>
      <permalink>adds-an-on-option-to-activerecord-observers</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>bugmash patch</tag>
      <title>Adds an :on option to ActiveRecord observers</title>
      <updated-at type="datetime">2009-08-04T18:14:10+01:00</updated-at>
      <user-id type="integer">7211</user-id>
      <user-name>Mike Gunderloy</user-name>
      <creator-name>Gabriel Gironda</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1639</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer" nil="true"></assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>+1 this is nice syntax

having trouble applying the patch - will try to apply to master and modify as necessary</body>
      <body-html>&lt;div&gt;&lt;p&gt;+1 this is nice syntax&lt;/p&gt;
&lt;p&gt;having trouble applying the patch - will try to apply to master
and modify as necessary&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-08-08T22:44:16+01:00</created-at>
      <creator-id type="integer">41923</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1639</number>
      <permalink>adds-an-on-option-to-activerecord-observers</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>bugmash patch</tag>
      <title>Adds an :on option to ActiveRecord observers</title>
      <updated-at type="datetime">2009-08-08T22:44:22+01:00</updated-at>
      <user-id type="integer">22242</user-id>
      <user-name>Dan Pickett</user-name>
      <creator-name>Gabriel Gironda</creator-name>
      <assigned-user-name nil="true"></assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1639</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">1366</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2010-01-20T11:11:16+00:00</created-at>
      <creator-id type="integer">41923</creator-id>
      <diffable-attributes type="yaml">--- 
:state: new
:tag: bugmash patch
:assigned_user: 
:milestone: 9903
</diffable-attributes>
      <milestone-id type="integer">27004</milestone-id>
      <number type="integer">1639</number>
      <permalink>adds-an-on-option-to-activerecord-observers</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>open</state>
      <tag>activerecord observers patch</tag>
      <title>Adds an :on option to ActiveRecord observers</title>
      <updated-at type="datetime">2010-01-20T11:11:21+00:00</updated-at>
      <user-id type="integer">65556</user-id>
      <user-name>Rizwan Reza</user-name>
      <creator-name>Gabriel Gironda</creator-name>
      <assigned-user-name>Pratik</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1639</url>
      <milestone-title>3.0</milestone-title>
    </version>
  </versions>
  <attachments type="array">
    <attachment type="Attachment">
      <code>6d927b0cf11d21563f5c46d3691d4be115086905</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2008-12-26T21:58:42+00:00</created-at>
      <filename>observer_on_option.diff</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">74005</id>
      <size type="integer">7182</size>
      <uploader-id type="integer">41923</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/74005/observer_on_option.diff</url>
    </attachment>
    <attachment type="Attachment">
      <code>7bb2dac4ab6daa2d8190bad892462bfd70b4cff0</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2009-01-27T22:45:14+00:00</created-at>
      <filename>observer_on_option.diff</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">82191</id>
      <size type="integer">7771</size>
      <uploader-id type="integer">41923</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/82191/observer_on_option.diff</url>
    </attachment>
  </attachments>
</ticket>
