Hi,
I''m still new to Ruby on Rails, and I want to utilize
ActiveRecord::Observer. I got Observer working under the rails
environment by putting my rb files under app/model and configuring
config/environment.rb. However, I want to automate the testing of my
site via command line. Is this possible?
So, I have a foo.rb
(bchin ~/setup/rails/pratice/app/models)cat foo.rb
class Foo < ActiveRecord::Base
end
and my foo_observer.rb
(bchin ~/setup/rails/pratice/app/models)cat foo_observer.rb
class FooObserver < ActiveRecord::Observer
def after_create(foo)
puts foo.id
Foo.find(foo.id)
end
end
and I registered foo_observer under config/environment
(bchin ~/setup/rails/pratice/app/models)grep ''foo''
../../config/environment.rb
config.active_record.observers = :foo_observer
And, when I go to the console, everything works as expected
(bchin ~/setup/rails/pratice/script)./console
Loading development environment (Rails 2.3.2)>> Foo.create
2
=> #<Foo id: 2>>>
How can I use ruby to test this? I tried creating a main.rb, which
''require'' foo and foo_observer, but that doesn''t seem
to work. What am I
missing? Thanks for any help anyone can provide.
--
Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.