<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Robby on Rails: Where did my observer go?</title>
    <link>http://www.robbyonrails.com/articles/2006/02/27/where-did-my-observer-go</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>thoughts.sort_by{|t| t[:topic]}.collect </description>
    <item>
      <title>Where did my observer go?</title>
      <description>&lt;p&gt;I was playing around with an application from &lt;code&gt;script/console&lt;/code&gt; and all of a sudden&amp;#8230; my &lt;a href="http://api.rubyonrails.org/classes/ActiveRecord/Observer.html"&gt;Observers&lt;/a&gt; just stopped working. It took me a while to figure out that when I would call &lt;code&gt;Dispatcher.reset_application!&lt;/code&gt;... it wouldn&amp;#8217;t reload config/environment.rb where I have defined the observers.&lt;/p&gt;


	&lt;p&gt;I really don&amp;#8217;t like that this is the current implementation for invoking Observers and adding them to the controllers is not kosher with my (do-it-in-script-console) approach.&lt;/p&gt;


	&lt;p&gt;The current solution?&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
# app/models/foo_bar.rb
class FooBar &amp;lt; ActiveRecord::Base
end

FooBarObserver.instance
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;... there needs to be a better way!&lt;/p&gt;
</description>
      <pubDate>Mon, 27 Feb 2006 23:05:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:bf47590a-2ccc-4c32-87a6-7b45325f630f</guid>
      <author>Robby Russell</author>
      <link>http://www.robbyonrails.com/articles/2006/02/27/where-did-my-observer-go</link>
      <category>observers</category>
      <category>activerecord</category>
      <category>rails</category>
    </item>
    <item>
      <title>"Where did my observer go?" by Robby Russell</title>
      <description>&lt;p&gt;Michael,&lt;/p&gt;


	&lt;p&gt;That assumes that your application is always engaged through your controllers. If you have a script that engages your models&amp;#8230; do you not want your observers to still work?&lt;/p&gt;</description>
      <pubDate>Tue, 14 Mar 2006 09:05:29 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:152d0df2-06d2-4cd0-a2f9-51058077fd04</guid>
      <link>http://www.robbyonrails.com/articles/2006/02/27/where-did-my-observer-go#comment-1938</link>
    </item>
    <item>
      <title>"Where did my observer go?" by Michael Gorsuch</title>
      <description>&lt;p&gt;Sorry for the late response:&lt;/p&gt;


	&lt;p&gt;I thought that was placed in the controller class.&lt;/p&gt;


	&lt;p&gt;For example, FooController has a line at the top of the class stating:&lt;/p&gt;


&lt;pre&gt;
  observer :foo_bar_observer
&lt;/pre&gt;</description>
      <pubDate>Tue, 14 Mar 2006 06:05:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:ec03d3a1-f265-4b2f-b959-3ac338aacb7d</guid>
      <link>http://www.robbyonrails.com/articles/2006/02/27/where-did-my-observer-go#comment-1937</link>
    </item>
    <item>
      <title>"Where did my observer go?" by Robby Russell</title>
      <description>&lt;p&gt;Michael,&lt;/p&gt;


	&lt;p&gt;Do you mean in &lt;strong&gt;config/environment.rb&lt;/strong&gt;?&lt;/p&gt;


	&lt;p&gt;Yes, you do&amp;#8230; but if you are in &lt;strong&gt;script/console&lt;/strong&gt; and run &lt;strong&gt;Dispatcher.reset_application!&lt;/strong&gt; it doesn&amp;#8217;t reload your Observers.&lt;/p&gt;</description>
      <pubDate>Tue, 28 Feb 2006 08:19:37 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:e306d3b8-95ea-4eca-8cf9-e4b7663f2365</guid>
      <link>http://www.robbyonrails.com/articles/2006/02/27/where-did-my-observer-go#comment-1888</link>
    </item>
    <item>
      <title>"Where did my observer go?" by Michael Gorsuch</title>
      <description>Robby &amp;#8211; I thought that you invoked Observers in rails as follows:
&lt;pre&gt;
observer :foo_bar_observer
&lt;/pre&gt;</description>
      <pubDate>Tue, 28 Feb 2006 06:21:13 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:97de8baf-31f3-4e29-8f82-8a4409ab05c1</guid>
      <link>http://www.robbyonrails.com/articles/2006/02/27/where-did-my-observer-go#comment-1887</link>
    </item>
  </channel>
</rss>
