# Raise error when key not present in factory

**URL:** https://discourse.rom-rb.org/t/raise-error-when-key-not-present-in-factory/361
**Category:** Issues
**Created:** [April 24, 2020, 4:37pm UTC](https://discourse.rom-rb.org/t/raise-error-when-key-not-present-in-factory/361 "2020-04-24T16:37:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![apohllo](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/apohllo/32/86_2.png) [@apohllo](https://discourse.rom-rb.org/u/apohllo)
#### Post date: [April 24, 2020, 4:37pm UTC](https://discourse.rom-rb.org/t/raise-error-when-key-not-present-in-factory/361/1 "2020-04-24T16:37:11Z")

</div>

I am using rom-factory and serveral times I was hit by the problem, that I use a key that **is not** an attribute/association of the object. This is mostly related to associations. Since the proper association is defined in the factory, there is no error, but a new instance of the related object is created.

I think it would save some time, not only for me, if the Factory checked for the definition of keys. If given key is not defined as an attribute or association of the object an exception should be raised.

---

<div class="post-metadata">

### Author: ![solnic](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/solnic/32/279_2.png) [@solnic](https://discourse.rom-rb.org/u/solnic)
#### Post date: [April 29, 2020, 8:58am UTC](https://discourse.rom-rb.org/t/raise-error-when-key-not-present-in-factory/361/2 "2020-04-29T08:58:07Z")

</div>

This is how it works. Are you using the latest version?
