This works fine when adding a new ticket through the browser. However when I send an email to my application I'll get the following exception:
E, [2013-03-19T20:19:50.352625 #8296] ERROR -- : uninitialized constant Ticket
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:230:in block in constantize'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:ineach'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in constantize'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/core_ext/string/inflections.rb:54:inconstantize'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:210:in observed_class'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:203:inobserved_classes'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:223:in observed_classes'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.12/lib/active_record/observer.rb:96:inobserved_classes'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:219:in initialize'
/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/singleton.rb:141:innew'
/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/singleton.rb:141:in block in instance'
/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/singleton.rb:139:insynchronize'
/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/singleton.rb:139:in instance'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:86:ininstantiate_observer'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:59:in block in instantiate_observers'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:59:ineach'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:59:in instantiate_observers'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.12/lib/active_record/railtie.rb:117:inblock (2 levels) in class:Railtie'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:36:in instance_eval'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:36:inexecute_hook'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:43:in block in run_load_hooks'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:42:ineach'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:42:in run_load_hooks'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.12/lib/active_record/base.rb:720:in'
/Users/tummam/Documents/Rails/ticketing/app/models/ticket.rb:1:in <top (required)>'
script/mailman_server:19:inblock (2 levels) in '
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/router.rb:66:in instance_exec'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/router.rb:66:inroute'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/message_processor.rb:19:in process'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/receiver/pop3.rb:41:inblock in get_messages'
/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/pop.rb:665:in each'
/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/pop.rb:665:ineach_mail'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/receiver/pop3.rb:40:in get_messages'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/application.rb:118:inblock in polling_loop'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/application.rb:115:in loop'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/application.rb:115:inpolling_loop'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/application.rb:75:in run'
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/application.rb:7:inrun'
script/mailman_server:16:in `'
To me it looks like the observer is the wrong idea to handle further processing. However as I envision it to be rather complex I wanted to decouple it from the receiving part of the application.
Can someone help me out with the observer problem or suggest a better method to do it?
I tried to decouple the receiving of a ticket from the further processing using observers.
For that I added an observer to tickets:
This works fine when adding a new ticket through the browser. However when I send an email to my application I'll get the following exception:
E, [2013-03-19T20:19:50.352625 #8296] ERROR -- : uninitialized constant Ticket
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:230:in
block in constantize'
each'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/inflector/methods.rb:229:in
constantize'
constantize'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/core_ext/string/inflections.rb:54:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:210:in
observed_class'
observed_classes'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:203:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:223:in
observed_classes'
observed_classes'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.12/lib/active_record/observer.rb:96:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:219:in
initialize'
new'/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/singleton.rb:141:in
/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/singleton.rb:141:in
block in instance'
synchronize'/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/singleton.rb:139:in
/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/singleton.rb:139:in
instance'
instantiate_observer'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:86:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:59:in
block in instantiate_observers'
each'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:59:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activemodel-3.2.12/lib/active_model/observing.rb:59:in
instantiate_observers'
block (2 levels) in class:Railtie'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.12/lib/active_record/railtie.rb:117:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:36:in
instance_eval'
execute_hook'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:36:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:43:in
block in run_load_hooks'
each'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:42:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activesupport-3.2.12/lib/active_support/lazy_load_hooks.rb:42:in
run_load_hooks'
'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.12/lib/active_record/base.rb:720:in
/Users/tummam/Documents/Rails/ticketing/app/models/ticket.rb:1:in
<top (required)>'
block (2 levels) in 'script/mailman_server:19:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/router.rb:66:in
instance_exec'
route'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/router.rb:66:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/message_processor.rb:19:in
process'
block in get_messages'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/receiver/pop3.rb:41:in
/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/pop.rb:665:in
each'
each_mail'/Users/tummam/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/pop.rb:665:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/receiver/pop3.rb:40:in
get_messages'
block in polling_loop'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/application.rb:118:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/application.rb:115:in
loop'
polling_loop'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/application.rb:115:in
/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/application.rb:75:in
run'
run'/Users/tummam/.rvm/gems/ruby-2.0.0-p0/gems/mailman-0.6.0/lib/mailman/application.rb:7:in
script/mailman_server:16:in `'
To me it looks like the observer is the wrong idea to handle further processing. However as I envision it to be rather complex I wanted to decouple it from the receiving part of the application.
Can someone help me out with the observer problem or suggest a better method to do it?