2 ms·
> configuration file (...) this file will be evaluated before the Rails application or (...) which makes referencing constants defined in the application code i
by viraptor 3y ago
> configuration file (...) this file will be evaluated before the Rails application or (...) which makes referencing constants defined in the application code impossible
That's not strictly true. You can use them just fine if there's a good reason to do it. For example this erb file works as expected:
<% require 'socket' %>
<%= Socket.gethostname %>
Useful if you have a specific provider for the config values.
- dansvetlov 3y agoIt's true that you can write arbitrary code in the template and reference other gems if needed. However, to reference constants located in any directory of your application, such as `app/` or `lib/`, you'd need to either explicitly require these files, overtaking the eager- or auto-loading mechanism of your app framework, or boot the whole application. So, you're right that it's not impossible, but it requires some additional considerations.