Acts_as_paranoid and Association Extensions (has_one trouble

Hi… Isn’t there a proper way or hack/workaround for the following?

  • For the example with unfortunate disabilities… look below,
    Usage of has_* (associationmethods) do {def with_deleted
    AccociatedModel#with_scope} {Paranoid’s#find_with_deleted}…
    The has_one associations give me a nil object when invoking it with
    Model.association_OBJECT.with_deleted. Has_many does like expected:
    Model.association_COLLECTION.with_deleted.

  • Example:
    The disability of my approach you see below after the lines with
    ########### signs…
    First on to: class Organization

class Organization < ActiveRecord::Base
acts_as_paranoid

has_one :contact_address, :as => :addressable, :dependent
=> :destroy do
def with_deleted
ContactAddress.with_scope(:find => {:conditions =>
“addressable_id = #{proxy_owner.id}”}) do
find_with_deleted(:all)
end
end
end

Loading development environment.

sc = SportClub.find_with_deleted(7)
=> #<SportClub:0xb769c1a4 @attributes={“number_of_members”=>nil,
“name”=>“Maastricht Wildcats”, “updated_at”=>“2007-08-03 21:50:44”,
“deleted_at”=>nil, “created_by”=>nil, “organization_code”=>“KNVB347”,
“url”=>nil, “type”=>“SportClub”, “updated_by”=>nil, “id”=>“7”,
“description”=>"", “deleted_by”=>nil, “created_at”=>nil}>

sc.destroy
=> #<SportClub:0xb769c1a4 @sportables_sports=[], @deleted_by=nil,
@contact_address=, @new_record_before_save=nil, @events=[],
@attributes={“number_of_members”=>nil, “name”=>“Maastricht Wildcats”,
“updated_at”=>“2007-08-03 21:50:44”, “deleted_at”=>nil,
“created_by”=>nil, “organization_code”=>“KNVB347”, “url”=>nil,
“type”=>“SportClub”, “updated_by”=>nil, “id”=>“7”, “description”=>"",
“deleted_by”=>nil, “created_at”=>nil}, @geographic=,
@accommodations=[],
@organizations_target_groups=[#<OrganizationsTargetGroup:0xb76c2908
@deleted_by=nil, @attributes={“updated_at”=>“2007-08-03 21:50:44”,
“target_group_id”=>“2”, “deleted_at”=>nil, “created_by”=>nil,
“updated_by”=>nil, “id”=>“1”, “deleted_by”=>nil,
“organization_id”=>“7”, “created_at”=>“2007-08-03 09:56:08”}>],
@site_addresses=[]>

sc = SportClub.find_with_deleted(7)
=> #<SportClub:0xb769889c @attributes={“number_of_members”=>nil,
“name”=>“Maastricht Wildcats”, “updated_at”=>“2007-08-03 21:50:44”,
“deleted_at”=>“2007-08-03 22:03:12”, “created_by”=>nil,
“organization_code”=>“KNVB347”, “url”=>nil, “type”=>“SportClub”,
“updated_by”=>nil, “id”=>“7”, “description”=>"", “deleted_by”=>nil,
“created_at”=>nil}>

#################################
Please tell me whyyyyy… isn’t there any way???
#################################

sc.contact_address.with_deleted
NoMethodError: You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.with_deleted
from (irb):4

sc.organizations_target_groups.with_deleted
=> [#<OrganizationsTargetGroup:0xb7603814
@attributes={“updated_at”=>“2007-08-03 21:50:44”,
“target_group_id”=>“2”, “deleted_at”=>“2007-08-03 22:03:12”,
“created_by”=>nil, “updated_by”=>nil, “id”=>“1”, “deleted_by”=>nil,
“organization_id”=>“7”, “created_at”=>“2007-08-03 09:56:08”}>]