Settings
This page provides a reference for all the available settings that can be used to configure Marten projects.
Common settings
allowed_hosts
Default: [] of String
An explicit array of allowed hosts for the application.
The application has to be explicitly configured to serve a list of allowed hosts. This is to mitigate HTTP Host header attacks. The strings in this array can correspond to regular domain names or subdomains (eg. example.com or www.example.com); when this is the case the Host header of the incoming request will be checked to ensure that it exactly matches one of the configured allowed hosts.
It is also possible to match all the subdomains of a specific domain by prepending a . at the beginning of the host string. For example .example.com will matches example.com, www.example.com, sub.example.com, or any other subdomains. Finally, the special * string can be used to match any Host value, but this wildcard value should be used with caution as you wouldn't be protected against Host header attacks.
It should be noted that this setting is automatically set to the following array when a project is running in debug mode (unless it is explicitly set):
[".localhost", "127.0.0.1", "[::1]"]
cache_store
Default: Marten::Cache::Store::Memory.new
The global cache store instance.
This setting allows to configure the cache store returned by the Marten#cache method (which can be used to perform low-level caching operations), and which is also leveraged for other caching features such as template fragment caching. Please refer to Caching to learn more about the caching features provided by Marten.
By default, the global cache store is set to be an in-memory cache (instance of Marten::Cache::Store::Memory). In test environments you might want to use the "null store" by assigning an instance of the `Marten::Cache::Store::Null to this setting. Additional caching store shards are also maintained under the umbrella of the Marten project or by the community itself and can be used as part of your application depending on your caching requirements. These backends are listed in the caching stores backend reference.
date_input_formats
Default:
[
"%Y-%m-%d", # '2024-10-25'
"%m/%d/%Y", # '10/25/2024'
"%m/%d/%y", # '10/25/06'
"%b %d %Y", # 'Oct 25 2024'
"%b %d, %Y", # 'Oct 25, 2024'
"%d %b %Y", # '25 Oct 2024'
"%d %b, %Y", # '25 Oct, 2024'
"%B %d %Y", # 'October 25 2024'
"%B %d, %Y", # 'October 25, 2024'
"%d %B %Y", # '25 October 2024'
"%d %B, %Y", # '25 October, 2024'
]
An array of default date input formats.
This array of default date input formats is used by the date schema field to parse date values from strings. Note that the date input formats coming from locales will be used with priority over the formats defined in this array.
date_time_input_formats
Default:
[
"%Y-%m-%d %H:%M:%S", # '2024-10-25 14:30:00'
"%Y-%m-%d %H:%M:%S.%f", # '2024-10-25 14:30:00.000000'
"%Y-%m-%d %H:%M", # '2024-10-25 14:30'
"%m/%d/%Y %H:%M:%S", # '10/25/2024 14:30:00'
"%m/%d/%Y %H:%M:%S.%f", # '10/25/2024 14:30:00.000000'
"%m/%d/%Y %H:%M", # '10/25/2024 14:30'
]
An array of default date input formats.
This array of default date input formats is used by the date_time schema field to parse date time values from strings. Note that the date time input formats coming from locales will be used with priority over the formats defined in this array.
debug
Default: false
A boolean allowing to enable or disable debug mode.
When running in debug mode, Marten will automatically provide detailed information about raised exceptions (including tracebacks) and incoming HTTP requests. As such this mode is mostly useful for development environments.
host
Default: "127.0.0.1"
The host the HTTP server running the application will be listening on.
installed_apps
Default: [] of Marten::Apps::Config.class
An array of the installed app classes. Each Marten application must define a subclass of Marten::Apps::Config. When those subclasses are specified in the installed_apps setting, the applications' models, migrations, assets, and templates will be made available to the considered project. Please refer to Applications to learn more about applications.
log_backend
Default: Log::IOBackend.new(...)
The log backend used by the application. Any Log::Backend object can be used, which can allow to easily configure how logs are formatted for example.