similar to: Getting controller_name from inside an Observer

Displaying 20 results from an estimated 200000 matches similar to: "Getting controller_name from inside an Observer"

2006 Jul 18
7
Observer not working
Help please. I''m trying to observe a User class, but I can''t get this to work, the after_create method never gets called... (the breakpoint never gets called) app/models/user_observer.rb: class UserObserver < ActiveRecord::Observer def after_create(user) breakpoint setting =
2007 Dec 12
3
undefined method: controller_name
With rspec 1.0.8 I have a spec in the directory: spec/units/controllers/application_controller_spec.rb require File.dirname(__FILE__) + ''/../../spec_helper'' class DummyController < ApplicationController def index raise "Prevent index from rendering" end end describe ApplicationController, "Handling errors in production", :behaviour_type =>
2007 Mar 19
3
controller_name with dynamic controllers
I''m writing a controller which should only be inherited from, something like the generic crud controller seen here: http:// geekonomics.blogspot.com/2006/07/crud-and-shared-controllers.html Now, in my spec, I would like to create a controller which inherits from the generic CRUDController, without actually creating the controller. This controller is *only* for testing. How can I
2007 Jan 29
2
Cryptic error message when no controller_name
Hi ! In the following spec: context "A project owner" do specify "can assign roles to other users" do # ... end end I get the following cryptic error message: 1) NoMethodError in ''A project owner can assign roles to other users'' undefined method `session='' for #<Object:0xb741bed4>
2006 May 24
1
Observer behavior differences between DEV and TEST environments ?
Hi all ! I''m having an issue and I can''t seem to make heads or tails of it. I am attempting to add an observer to a model object. I created app/models/greenback_transaction_observer.rb, inherited from AR::Observer, defined methods, registered in config/environment.rb, but things don''t work... So, I took a step back and put in the following code: class
2006 Feb 22
0
How to get model observer to work?
I can''t seem to get a model observer to work. In my environment.rb I have: config.active_record.observers = :item_observer In item_observer.rb I have: class ItemObserver < ActiveRecord::Observer observe Item def after_update(item) if @old.active != item.active logger.debug ''observer#after_update'' #... end @old = nil end def
2007 Apr 12
1
rspec on rails: undefined method ''controller_name''
Im trying to write a controller spec, but when I run it I get an error like the one below. I found Bug6707 (http://rubyforge.org/pipermail/rspec-devel/2007-March/002147.html ), but I get the error no matter how I run the spec ( whether I use rake or not) Any ideas? I am using 0.8.2 The Error: C:/rails/InstantRails/ruby/lib/ruby/gems/1.8/gems/rspec-0.8.2/lib/spec/expectati ons/sugar.rb:14:in
2007 Dec 14
0
async-observer rails plugin
I''m pleased to announce the existence of async-observer. This is the very first public release. In the future I''ll confine announcements to the beanstalk-talk mailing list. WHAT IS ASYNC OBSERVER? ----------------------- Async Observer is a Rails plugin that provides deep integration with Beanstalk. beanstalkd is a fast, distributed, in-memory work-queue service. Its
2006 Jun 01
0
question about observer callbacks
I''m not sure how to implement this so I''ll describe what I currently have done then what I wish to have happen currently, I have a generic observer for several models class AuditObserver < ActiveRecord::Observer observe Foo, Bar def after_update(model) model.log("UPDATED " + Time.now.strftime("%m-%d-%Y %H:%M")) end def after_create(model)
2006 Apr 26
1
Observer best practices
I''ve seen two ways of connecting observers: 1) In the observer class put observe MyModel 2) In the controller class put observer :my_observer What is the difference between these two? Also, is it necessary to put in the observer class the following? MyObserver.instance Jose -- Posted via http://www.ruby-forum.com/.
2006 Feb 19
0
newbe: observer setup
Hi All, Having problem setting up an observer to log changes to a database. I have following the Prag Rails book but think I have something missing. I am trying a simple puts to see if the observer is working, but getting nothing on the console. Here is what I have. I don''t get any errors. Thanks for any suggestions/references to debugging. Dave The two models: display_ad.rd
2006 Jul 17
1
Access session data from observer
I am writing an internal time tracking app, and am curious to know if it''s possible to access the session data from an observer. Each ''user'' has a list of their current projects, which is updated (via an observer) everytime a ''project'' or ''hour'' is saved. To find out who the current user is, I am trying to do a
2010 Aug 17
0
Dose custom rake task ignore observer?
I have an observer which will do some tidy up work around Model A. But when I create or destroy A''s instance inside a custom rake task, the observer seems not get called at all? Can some one explain this? -- 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
2005 Dec 07
3
ActiveRecord::Observer problem
Hi all, I have a problem with an observer. I have a simple observer... class ActivityObserver < ActiveRecord::Observer observe Customer def after_create(model) bind_params(model) @al.action = "create" @al.save logger "#{model.id} : created" end private def bind_params(model) @al = ActivityLog.new @al.user_id = User.current.id
2006 Jul 11
0
Access session from observer?
I am writing a logger observer that provides an audit trail for most events that touch my AR models. I am using the acts_as_authenticated plugin for user login. What would be the best way to expose the current user to my observer? I''m not looking to violate MVC here (well, maybe a little -- though a logger seems more like a controller than a model to me). I just want the logger to
2008 Jul 21
1
Re: Observer
eh, like so? def after_create(model) generate_hotel_param_files(model.id) generate_hotel_setup_files(model.id) end def after_update(model) generate_hotel_param_files(model.id) generate_hotel_setup_files(model.id) end On Jul 21, 9:59 am, David Nguyen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > Hi, > I have to make an observer if a
2006 Apr 26
0
Observer method names
I haven''t seen it documented anywhere, but can observer methods be given a prefix in their name like ''after_'' followed by my controller''s method name? For instance I have a couple of methods called ''create'' and ''create_reply''. Can I have ''after_create'' and ''after_create_reply'' in my
2006 Nov 21
0
Observer + acts_as_taggable plugin = dead app
so i have found that if i try to place an observer on a model that is using the acts_as_taggable plugin, my app will not start up. this is what i get in the mongrel startup log /Applications/Locomotive2/Bundles/rmagickRailsSept2006_ppc.locobundle/framework/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1129:in `method_missing'': undefined local variable or method
2006 Apr 06
1
observer doesn''t react
i followed the observer documentation [1] and created, and registered an observer. i had to realise that the observer doesn''t work at all -- in fact the rails application does not even start -- with acts_as_taggable, for whatever reason. i must admit that i''m still using ruby 1.8.2. however, after commenting the acts_as_taggable instruction out the application runs smoothly
2006 Jan 11
0
RE: RE: Event.observer - unordered list problems
I just realized I made a mistake... in the first numbered solution, the != should be == ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Ryan Gahl Sent: Wednesday, January 11, 2006 2:28 PM To: