07-19-2023, 01:27 AM
I'm defining a constant in an initializer in Rails using the following syntax:
MyModule.const_set('MYCONSTANT','foobar')
It works, if I start a console and write
MyModule::MYCONSTANT
I receive foobar as expected.
The problem is, when I try to call it in a Model the constant is not there.
Where should D dynamically define my constant that it can be available as well in my models?
If I statically define it in my lib/mymodule.rb it works but I would like to define some constants at runtime.
MyModule.const_set('MYCONSTANT','foobar')
It works, if I start a console and write
MyModule::MYCONSTANT
I receive foobar as expected.
The problem is, when I try to call it in a Model the constant is not there.
Where should D dynamically define my constant that it can be available as well in my models?
If I statically define it in my lib/mymodule.rb it works but I would like to define some constants at runtime.