Skip to main content

Configuration

Initializer (config/initializers/habarico.rb):

Habarico.setup do |config|
config.resources = [
{ admin: [:categories, :orders, :order_items, :shipments, :communications] }
]
config.routing_url_prefix = ENV.fetch('URL_PREFIX') { '' }
config.routing_scope = 'apps'
config.currency = 'CZK'
end

Resources can be plain symbols (flat namespace) or hashes where the key is the URL/module namespace and the value is an array of resource names within that namespace.

OptionDescriptionDefault
resourcesArray of resource names (symbols or namespace hashes)[]
routing_url_prefixURL prefix applied to all generated routes''
routing_scopeRails module scope used for controller lookupnil
currencyDefault currency code for number formatting'CZK'
search_unaccent_enabledDiacritics-insensitive fulltext matching and highlighting; needs the PostgreSQL unaccent extensionfalse
authenticate_methodMethod Habarico calls (via send) as its authentication before_action — see Authentication:authenticate_request
default_page_limitPage size of a list endpoint when the request sends no limit — see Paginationnil (20)
max_page_limitLargest limit a list request may ask for; above it the endpoint answers 422 — see Paginationnil (1000)
base_controller_classParent class of Habarico's own engine controllers (schema, global search, user preferences). Point it at the application's 'ApplicationController' to reuse its authentication — see Authentication'ActionController::API'

Habarico.setup simply yields Habarico::Config, so every option is also readable as Habarico::Config.currency at runtime.

search_unaccent_enabled mirrors the Python ADMIN_SEARCH_UNACCENT_ENABLED setting — see Filtering and searching.