# Best way to add attributes dynamically

**URL:** <https://discuss.emberjs.com/t/best-way-to-add-attributes-dynamically/9794>\
**Category:** Uncategorized\
**Created:** [February 16, 2016, 10:18am UTC](https://discuss.emberjs.com/t/best-way-to-add-attributes-dynamically/9794 "2016-02-16T10:18:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GCorbel](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/gcorbel/32/11010_2.png) [@GCorbel](https://discuss.emberjs.com/u/GCorbel)\
**Post date:** [February 16, 2016, 10:18am UTC](https://discuss.emberjs.com/t/best-way-to-add-attributes-dynamically/9794/1 "2016-02-16T10:18:37Z")

</div>

Hi,

I’m looking for a way to add attributes based on custom inputs. I did something like this in an initializer :

```
export function initialize(applicationInstance) {
  var store = applicationInstance.lookup('service:store');

  store.findAll('CustomField').then((customFields) => {
    var attributes = {};
    customFields.forEach((customField) => {
      attributes[customField.get('property')] = DS.attr();
    });
    Subscription.reopen(attributes);
  });
} 

```

It works but asynchrously so if I instanciate an object before the success of the call, it will not have the custom attributes. I can probably do it synchronously but I will have perf problem. It will slow the load of the app.

There may be a way to override the serialization but I don’t know if it’s a good solution because I will use this attributes in the application and they will not be visible. Kind of “Ghost attributes”.

With a relationship, I will have the same problems.

What’s the best solution?

Thanks!
