Issues with has_many, belongs_to and dependency settings

I have 2 models SmsAddress & OutboundSmsAtom

SmsAddress {

has_many :other_objects, :dependency => :nullify

}

OutboundSmsAtom {
#note this object also “belongs_to” other objects if that matters
belongs_to :this_object

}

Whenever I try to destroy an object of type ThisObject, which at the
time
has 0 “children” OtherObjects I get the following type of error message

address.destroy
NameError: uninitialized constant OuboundSmsAtom
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc
ies.rb:100:in const_missing' from /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc ies.rb:131:inconst_missing’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependenc
ies.rb:133:in const_missing' from (eval):1:inconfigure_dependency_for_has_many’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/callbacks.
rb:337:in callback' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/callbacks. rb:330:incallback’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/callbacks.
rb:320:in destroy_without_transactions' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactio ns.rb:122:indestroy’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/connection
_adapters/abstract/database_statements.rb:51:in transaction' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactio ns.rb:91:intransaction’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactio
ns.rb:118:in transaction' from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.3/lib/active_record/transactio ns.rb:122:indestroy’
from (irb):18

exit

If I turn of the :dependent property it then works fine. I’m sort of
stumped. Thanks in advance if anyone has a fix, or even better a fix
for
what must be some sort of conceptual mistake I’m making.

Cheers - Shane

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs