I''m getting the dreaded "DEPRECATION WARNING: observer is deprectaed" notice when running functional tests. I use an observer in a controller to instantiate a a UserObserver object to observe changes to my User model. This is documented on page 380 of the Agile Web Development with Rails (Second Edition). If this use is indeed deprecated, what is the appropriate way to instantite an observer from a controller? Gregg --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''m using an Observer as well, using that same example (well, from the 2nd edition of that book) and I''m getting the same warning. It goes on: "See http://www.rubyonrails.org/deprecation for details," but there''s really nothing on that web page but a coming-soon message. Below is the whole message I get, with a second deprecation warning that seems related, and so I was also wondering if anybody knew what is going on with Observer and why this change is being made? There is another way to implement an observer, calling instance: MyObserver.instance But that requires initializing it somewhere, which is what the observer method of ActionController was doing... Anybody? This is a really useful facility, it would be a shame to strip it from Rails 2.0 if there isn''t a compelling replacement. -Billy DEPRECATION WARNING: observer is deprecated and will be removed from Rails 2.0 See http://www.rubyonrails.org/deprecation for details. (called from ./script/../config/../app/controllers/things_controller.rb:3) DEPRECATION WARNING: depend_on is deprecated and will be removed from Rails 2.0 See http://www.rubyonrails.org/deprecation for details. (called from observer_without_deprecation at /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/deprecated_dependencies.rb:29) On Nov 29 2006, 9:28 pm, "Gregg" <g...-+7pv9bBeZkoOi5MzEVbBygC/G2K4zDHf@public.gmane.org> wrote:> I''m getting the dreaded "DEPRECATIONWARNING:observeris deprectaed" > notice when running functional tests. I use anobserverin a controller > to instantiate a a UserObserver object to observe changes to my User > model. This is documented on page 380 of the Agile Web Development with > Rails (Second Edition). If this use is indeeddeprecated, what is the > appropriate way to instantite anobserverfrom a controller? > > Gregg--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> I''m using an Observer as well, using that same example (well, from the > 2nd edition of that book) and I''m getting the same warning. It goes > on: "See http://www.rubyonrails.org/deprecation for details," but > there''s really nothing on that web page but a coming-soon message.Set config.observers in your environment.rb. config.observers = [:foo_observer] -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the tip, but I get an error when trying this: .../config/environment.rb:41: undefined method `observers='' for #<Rails::Configuration:0x3128cc> (NoMethodError) I don''t see anything in railties/lib/environment.rb to support this. Also, I found some references (from October) about this mechanism being incompatible with Mongrel, although that may have since been resolved. (http://rubyforge.org/pipermail/mongrel-users/2006-October/001927.html) Gregg http://www.kellogg-assoc.com On Jan 25, 7:25 pm, "Rick Olson" <technowee...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m using an Observer as well, using that same example (well, from the > > 2nd edition of that book) and I''m getting the same warning. It goes > > on: "Seehttp://www.rubyonrails.org/deprecationfor details," but > > there''s really nothing on that web page but a coming-soon message.Set config.observers in your environment.rb. > > config.observers = [:foo_observer] > > -- > Rick Olsonhttp://weblog.techno-weenie.nethttp://mephistoblog.com--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 1/26/07, Gregg <gregg-+7pv9bBeZkoOi5MzEVbBygC/G2K4zDHf@public.gmane.org> wrote:> > Thanks for the tip, but I get an error when trying this: > > .../config/environment.rb:41: undefined method `observers='' for > #<Rails::Configuration:0x3128cc> (NoMethodError) > > I don''t see anything in railties/lib/environment.rb to support this. > Also, I found some references (from October) about this mechanism being > incompatible with Mongrel, although that may have since been resolved. > (http://rubyforge.org/pipermail/mongrel-users/2006-October/001927.html)DOH! config.active_record.observers = ... There is an example in the default environment.rb: http://dev.rubyonrails.org/browser/tags/rel_1-2-1/railties/environments/environment.rb#L38 That issue you linked to has been resolved. The problem was, it would load your models right away, and bomb if your models used some plugin features that hadn''t been loaded yet. Observers now load after plugins. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks! That did the trick. Even though it''s there in the config file, it was almost impossible to find in the online documentation. The online API documentation doesn''t include Rails::Configuration (not in http://api.rubyonrails.org/ anyway). Searching for it gives the cryptic notice that config.active_record is "A stub for setting options on ActiveRecord::Base" which can be infered from ActiveRecord::Observing::ClassMethods ( http://railsmanual.org/module/ActiveRecord%3A%3AObserving%3A%3AClassMethods ). Still, not obvious. Perhaps the deprecation page, whenever it comes about, will make this clear. Also, too bad they didn''t get this into the Agile v2 book. Gregg www.kellogg-assoc.com On Jan 26, 1:20 pm, "Rick Olson" <technowee...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 1/26/07, Gregg <g...-+7pv9bBeZkoOi5MzEVbBygC/G2K4zDHf@public.gmane.org> wrote: > > > > > Thanks for the tip, but I get an error when trying this: > > > .../config/environment.rb:41: undefined method `observers='' for > > #<Rails::Configuration:0x3128cc> (NoMethodError) > > > I don''t see anything in railties/lib/environment.rb to support this. > > Also, I found some references (from October) about this mechanism being > > incompatible with Mongrel, although that may have since been resolved. > > (http://rubyforge.org/pipermail/mongrel-users/2006-October/001927.html)DOH! > > config.active_record.observers = ... > > There is an example in the default environment.rb: > > http://dev.rubyonrails.org/browser/tags/rel_1-2-1/railties/environmen... > > That issue you linked to has been resolved. The problem was, it would > load your models right away, and bomb if your models used some plugin > features that hadn''t been loaded yet. Observers now load after > plugins. > -- > Rick Olsonhttp://weblog.techno-weenie.nethttp://mephistoblog.com--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---