Skip to content

Configuring

Carlos edited this page Aug 18, 2018 · 15 revisions

Some resources may have extra configurations that can be set in your application.rb as following:

# application.rb
Torque::PostgreSQL.configure do |c|
  c.enum.initializer = true
end

General configurations

These are the keys available to configure general features:

eager_load Set if any information that requires querying and searching or collecting information shoul be eager loaded. This automatically changes when rails same configuration is set to true.
Default value: false

irregular_models Set a list of irregular model names when associated with table names. It uses the 'table_name' => 'model_name' format. This is widely used for inheritance, because record types need to be associated with a model class.
Default value: {}

Auxiliary statements configurations

These are the keys available to configure Auxiliary statements features:

auxiliary_statement.send_arguments_key Define the key that is used on auxiliary statements to send extra arguments to format string or send on a proc.
Default value: :args

Enum configurations

These are the keys available to configure Enum features:

enum.initializer Indicates if the enum features on ActiveRecord::Base should be initiated automatically or not. When it is set to false, you have to manually call enum :column in each model that you want to use this resource.
Default value: false

enum.base_method The name of the method to be used on any ActiveRecord::Base to initialize model-based enum features.
Default value: :enum

enum.save_on_bang Indicates if bang methods like 'disabled!' should update the record on database or not.
Default value: true

enum.namespace Specify the namespace of each enum-type of value, such as ::Enum::Roles.
Default value: ::Enum

enum.i18n_scopes Specify the scopes for I18n translations.
Default value:

[ 'activerecord.attributes.%{model}.%{attr}.%{value}',
  'activerecord.attributes.%{attr}.%{value}',
  'activerecord.enums.%{type}.%{value}',
  'enum.%{type}.%{value}',
  'enum.%{value}' ]

enum.i18n_type_scope Specify the scopes for I18n translations, detached from model.
Default value: # Same list as before but without items that have ${attr} or %{model}

Inheritance configurations

These are the keys available to configure Inheritance features:

inheritance.inverse_lookup Define the lookup of models from their given name to be inverted, which means that they are going to form the last namespaced one to the most namespaced one. If you prefer User::Role instead of UserRole as model name, set this to false to improve performance.
Default value: true

inheritance.record_class_column_name Determines the name of the column used to collect the table of each record. When the table has inheritance tables, this column will return the name of the table that actually holds the record.
Default value: :_record_class

inheritance.auto_cast_column_name Determines the name of the column used when identifying that the loaded records should be casted to its correctly model. This will be TRUE for the records mentioned on cast_records.
Default value: :_auto_cast

Clone this wiki locally