# Can't replace/remove a has\_one related object

**URL:** <https://www.ruby-forum.com/t/cant-replace-remove-a-has-one-related-object/92169>\
**Category:** Rails\
**Created:** [April 16, 2007, 8:54pm UTC](https://www.ruby-forum.com/t/cant-replace-remove-a-has-one-related-object/92169 "2007-04-16T20:54:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 16, 2007, 8:54pm UTC](https://www.ruby-forum.com/t/cant-replace-remove-a-has-one-related-object/92169/1 "2007-04-16T20:54:17Z")

</div>

All,

I have two models, Job and Document.

Job has\_one :document

I perform this:

@current\_job.document.destroy

which successfully removes all the appopriate DB records.

However, if I attempt to do:

@current\_job.document = nil

OR

@current\_job.build\_document(…)

I get a TypeError: can’t modify frozen hash exception.

Why can’t I reassign nil to the associated document for my job?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [April 16, 2007, 9:02pm UTC](https://www.ruby-forum.com/t/cant-replace-remove-a-has-one-related-object/92169/2 "2007-04-16T21:02:51Z")

</div>

OK, I see now that the destroy instance method says that it “freezes  
this instance to reflect that no changes should be made (since they  
canâ€˜t be persisted).”

Fine. I don’t want to work with that instance any more.

Why can’t I reassign to the has\_one relationship?

Wes
