similar to: adding observers outside environment.rb

Displaying 20 results from an estimated 10000 matches similar to: "adding observers outside environment.rb"

2006 Mar 04
2
Declaring ActiveRecord observers
Hello I''m using the ''act_as_authenticated'' plugin to implement a small and simple authentication system in my app. Everything is working just fine and the world is a better place to live in. The plugin creates a ActiveRecord observer in order to send the newly registered user a confirmation e-mail. Per the API docs [1], one should declare the observer in the
2010 Oct 03
1
Rails 3 observers
Rails Guides says: ...the UserObserver ... would be saved as app/models/user_observer.rb and registered in config/environment.rb this way: config.active_record.observers = :user_observer But the observer registration above doesn''t work because there is no ''config''. For now, I''ve put it in the config/environments/[APP_ENV].rb but that seems really sloppy and
2007 Jan 22
1
Observed models cause failures with DRBSpec ?
Hi all ! I don''t believe I am the only one using model observers, right ? Well, here''s a nice one: $ drbspec spec . Finished in 0.125322 seconds 1 specification, 0 failures $ drbspec spec F 1) ''A user with an inactive and an active project should be able to return active projects only'' FAILED [] should == [#<Spec::Mocks::Mock:0xb75590bc
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 =
2009 May 12
2
rails 2.3.2 is not generating environment.rb properly
problem: rails 2.3.2 is not generating config.action_controller.session_store = :active_record_store in environment.rb this is the code in environment.rb --------------------------------------------------------------------------- # Be sure to restart your server when you modify this file # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION =
2008 Sep 18
1
user_observer (restful_authentication) causes failure in loading rails
I have restful_authentication in use on an app and it has been working fine, but I recently was changing the account creation flow and needed to enable the UserObserver. I did so by including it in the environment.rb (config.active_record.observers = :user_observer) and Rails wouldn''t start. I got the following error; source/communitysites/vendor/rails/activerecord/lib/active_record/
2007 Oct 24
1
Attachment_fu and observers/emailing
Hi all, I''m developing a site where a user can upload their CV/resume with a profile, and am using restful_authentication for this with attachment_fu to handle the file uploading. When a user creates their profile/user account, I''ve got an observer that will email the site admin with a copy of the uploaded CV. My user_observer looks something like: class UserObserver <
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 Aug 16
1
Active Record Observers causing 404''s and other weird issues
Hi all. I''ve got a simple AR Observer: class NewOrderObserver < ActiveRecord::Observer observe NewOrder def after_create(object) Note.create(...) end end In environment.rb I have the following line: config.active_record.observers = :new_order_observer And in application.rb I have: NewOrderObserver.instance Aside from simply not working, it''s causing
2010 Mar 09
1
db:migrate fails after upgrade to Rails 2.3.5
Hi -- I''m upgrading an app from Rails 2.0.2 to 2.3.5 in development on a Mac OS/X Leopard. I unfroze the old Rails files, froze the 2.3.5 gem on the machine into the app, and some quick tests of the app showed no problems. However, after trying to run rake db:migrate, it fails silently. Run with trace I get the output below. I gather it might be related to plugin initialization or
2006 May 03
0
Testing Observers
Greetings all, As a Noob, I''ve been diligently working my way through the AWD4R book and finally arrived at the part about observers -- which BTW I think are very cool tech. Anyhow, I got the Audit Observer working. Now I want to test it and perhaps examine it''s attributes and methods to make sure it does what is expected of it. For example, one thing I would like to do
2006 Nov 04
0
ActiveRecord Observers and Model breakage.
I''m attempting to assign ActiveRecord Observers to some of my models, specified in config/environment.rb like so, config.active_record.observers = :presentation_observer, :asset_observer, :tag_observer My models use plugins which extend ActiveRecord::Base, including Sebastian Kanthak''s file_column Attempting to boot mongrel yields:
2006 Feb 22
2
Removing form observers
Hi, I''m developing a Rails app which uses dynamic forms. To implement these, I''ve used AJAX and Rails''s built-in form observers. Unfortunately, I''m having a problem. This is how the form starts: * Country select box [OBSERVED] (Republic of Ireland selected) * County select box [OBSERVED] (none selected, list of Republic of Irish counties in the drop down)
2010 Apr 16
1
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
2006 Mar 10
9
Observers?
Hello all! I''m having an issue with Observers, and I''m hoping someone knows the answer. Here is the definition: app/models/vehicle_observer.rb > class VehicleObserver < ActiveRecord::Observer > def after_save(vehicle) > breakpoint > if vehicle.has_new_mil_indication? > UserMailer.deliver_mil_notice(vehicle) > end > end > end
2007 Jan 18
1
spec''ing models with observers that send mail
I''m spec''ing a model with an observer that sends mail. Mailers behave similarly to controllers, so to make the whole thing work, I believe something like integrate_views has to be available. Has anyone dealt with observers and ActionMailer? Thanks
2012 Dec 06
2
Bye Bye, Observers
Observers will be no more as of Rails 4, farewell, never been much of a fan. However, I''m using it in one of my gems which enables model attributes for use with a WYSIWYM editor. The resulting markup is persisted, but in order to use it in a view, it has to be nokogiried in a helper which fragment caches the result. This cache has to be zapped once the model instance is either
2007 Nov 17
0
spec.opts default --load-by and observers
When specing observers I usually put them into models directory under / spec. Then, when specs are run observer class can''t be found unless I remove --load-by mtime from spec.opts. My question is what''s the Big Idea behind loading specs in that order by default? Shouldn''t default spec.opts contain just formatting options? Because as you see it DOES cause problems
2006 Jul 21
2
ActiveRecorod observers don''t work in mongrel?
Am i wrong or do ActiveRecord observers not work in mongrel? Is there a work around for this? I am 100% sure of this because in my observer i put raise "whatever". Whenever I try update the model using the mongrel server I get a successful save. If I do it in webrick I get an exception raised. Any ideas what I should do? Because webrick is pretty annoying to work with. Thank
2009 Sep 27
1
Switchboard - Easy to use global ActiveRecord event listeners
Switchboard is a simple, event-observing framework for ActiveRecord. It''s designed to make it easy to add observers for all models in your app, and to easily turn them on and off selectively. Intallation gem sources -a http://gems.github.com sudo gem install zilkey-switchboard Usage First, require switchboard above your rails initializer: # environment.rb require