attr_json icon indicating copy to clipboard operation
attr_json copied to clipboard

Defining attrs on runtime?

Open mbajur opened this issue 4 months ago • 0 comments

I was thinking - would that be possible to somehow define attr_jsons on record on runtime rather than defining them in advance on model definition?

Something like:

record = MyModel.last
record.define_attr_json :my_string, :string
record.my_string #=> "Hello"

In my current setup, every customer (tenant) of my app can define his own set of custom fields for "Project" model therefore i can't have them defined globally, i have to be able to re-load whatever custom fields tenant has defined on every target record load.

Also, i'm totally okay with some #send(:private_method) hacking or any sort of hacking to make that work :)

mbajur avatar Oct 16 '24 09:10 mbajur