Hi,
I'm still new to Ruby on Rails, and I want to utilize
ActiveRecord::O bserver. 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
and my foo_observer.rb
and I registered foo_observer under config/environment
And, when I go to the console, everything works as expected
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.
I'm still new to Ruby on Rails, and I want to utilize
ActiveRecord::O bserver. 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
Code:
(bchin ~/setup/rails/pratice/app/models)cat foo.rb class Foo < ActiveRecord::Base end
Code:
(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
Code:
(bchin ~/setup/rails/pratice/app/models)grep 'foo' ../../config/environment.rb config.active_record.observers = :foo_observer
Code:
(bchin ~/setup/rails/pratice/script)./console Loading development environment (Rails 2.3.2) >> Foo.create 2 => #<Foo id: 2> >>
'require' foo and foo_observer, but that doesn't seem to work. What am I
missing? Thanks for any help anyone can provide.