Displaying 20 results from an estimated 10000 matches similar to: "Rails 3 observers"
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 =
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/
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
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 <
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
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 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
2006 Jul 07
3
Observer and Plugin conflict...
Hi fellas,
I have setup the acts_as_authenticated plugin and activated the
UserObserver to send activation emails.
I also have a homemade security plugin which adds methods to
ActiveRecord::Base like let_read and let_write.
On the server start, those two enter in conflict because the Observer
does something with the User model but it can''t find the let_read and
the let_write
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
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
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 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
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 Apr 28
0
Minimum needed to observe a model
I have a model called Post and a observer called PostObserver. I also
have in environment.rb file the line:
config.active_record.observers = :post_observer
I read that observers default to the model with the same name, but the
model class isn''t being observed.
Observe works if I put in the ForumController:
observer :post_observer
But this doesn''t seem right.
Jose
--
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
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 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 Aug 30
8
experimental rails story adapter in trunk
For those of you interested in getting a jump on learning about and
using the new Story Runner in a Rails app, I''ve added an experimental
Rails-Story adapter to trunk.
You can see how to use it here:
http://pastie.caboo.se/92320
This is PURELY EXPERIMENTAL, however it actually works and will likely
not change much in the way that it does work.
Happy hacking!
David
2006 Nov 19
1
ActiveRecord save-update not performed ?
I try to understand the following issue :
- when creating a new User record, I use an UserObserver to trap the
before_save call back and send an email
def after_create(user)
UserNotifier.deliver_signup_notification(user)
end
- Once created a user can ask for a password reset, which is also
trapped by the UserOberver
def after_save(user)
UserNotifier.deliver_reset_password(user) if
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 =