Displaying 20 results from an estimated 9000 matches similar to: "Testing Observers"
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
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
2008 Feb 05
0
adding observers outside environment.rb
I need to add an ActiveRecord observer and thought I should follow
Rails 2 intent by not changing the base environment.rb
I create a file config/initializers/observers.rb but don''t know what
to add to it.
I can''t add: config.active_record.observers = :user_observer
Since "config" isn''t defined in the scope of the initializer file and
I don''t know if
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
2008 Feb 19
0
Issue with Observers and has_one association...
Hey Guys,
I''m getting a peculiar bug working with Observers and has_one
associations. When a has_one association is invoked by an Observer it
always returns null. I looked in the development.log file and the SQL
for the has_one association isn''t even being executed. On the other
hand, when I replace the has_one association with just a hand crafted
method, it does get called
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
2012 Jun 01
0
Association callbacks on model observers
Hello all first post so be kind,
Is there a way to use association callbacks on model observers? For
instance if I have a has_and_belongs_to_many association on my model I can
add a private method for instance to be called on the :after_add, is there
a way to move this to an observer I have created for this model?
Thanks
.FxN
--
You received this message because you are subscribed to the
2007 Jul 30
4
Stubbing Observers in rails?
In most of my tests I''d like to be able to stub out the observers for my
models, but I''m not sure the best way to do this. I doesn''t look like there
is a way to stub all instance methods, and I don''t seem to be able to stub
early enough to stub out the observer as it''s instantiated. I can think of
several hackish ways to get around it, but I was
2005 Nov 08
1
Event.observers - I''m totally list - please help
Hello,
I need some help on how to use the Event.observers - thank you in advance
for your input.
<div class="navcontainer">
<ul id="nav">
<li class="button">
<img src="images/spacer.gif" width="20" height="20">
</li>
<li class="button">
<img
2005 Feb 09
1
looking for responsible iax provider, aftermath
Greetings,
I'd like to thank everyone that has responded to my original email. I
have received information from several companies, and will be testing
several of them.
I also would like to update a statement from my original message to
clarify it:
>My strikelist: nufone, voicepulse, iax/sixtel
The strikelist is just a list of carriers that didn't meet the needs a
resonable
2006 Dec 04
1
Model Testings with Observers
I have a Rails model that has an observer. The function of the
observer is to send an email when a particular state change occurs in
the model. Because the template rendering code is not loaded when
doing model testing, I''ve had to shut off the email functionality of
the observer for testing.
Is there a better way to handle this?
Thanks
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
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