<commit_before>h2. Configuring Rails Applications

This guide covers the configuration and initialization features available to Rails applications. By referring to this guide, you will be able to:

* Adjust the behavior of your Rails applications
* Add additional code to be run at application start time

endprologue.

h3. Locations for Initialization Code

Rails offers (at least) four good spots to place initialization code:

* application.rb
* Environment-specific Configuration Files
* Initializers (load_application_initializers)
* After-Initializers

h3. Running Code Before Rails

To run some code before Rails itself is loaded, simply put it above the call to
+require 'rails/all'+ in your +application.rb+.

h3. Configuring Rails Components

In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The +application.rb+ and environment-specific configuration files (such as +config/environments/production.rb+) allow you to specify the various settings that you want to pass down to all of the components. For example, the default Rails 3.0 +application.rb+ file includes this setting:

<ruby>
  config.filter_parameters += [:password]
</ruby>

This is a setting for Rails itself. If you want to pass settings to individual Rails components, you can do so via the same +config+ object:

<ruby>
config.active_record.timestamped_migrations = false
</ruby>

Rails will use that particular setting to configure Active Record.

h4. Rails General Configuration

* +config.cache_classes+ controls whether or not application classes should be reloaded on each request.

* +config.cache_store+ configures which cache store to use for Rails caching. Options include +:memory_store+, +:file_store+, +:mem_cache_store+ or the name of your own custom class.
<commit_msg>Mention what cache_classes defaults to in all three default environments<commit_after>h2. Configuring Rails Applications

This guide covers the configuration and initialization features available to Rails applications. By referring to this guide, you will be able to:

* Adjust the behavior of your Rails applications
* Add additional code to be run at application start time

endprologue.

h3. Locations for Initialization Code

Rails offers (at least) four good spots to place initialization code:

* application.rb
* Environment-specific Configuration Files
* Initializers (load_application_initializers)
* After-Initializers

h3. Running Code Before Rails

To run some code before Rails itself is loaded, simply put it above the call to
+require 'rails/all'+ in your +application.rb+.

h3. Configuring Rails Components

In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The +application.rb+ and environment-specific configuration files (such as +config/environments/production.rb+) allow you to specify the various settings that you want to pass down to all of the components. For example, the default Rails 3.0 +application.rb+ file includes this setting:

<ruby>
  config.filter_parameters += [:password]
</ruby>

This is a setting for Rails itself. If you want to pass settings to individual Rails components, you can do so via the same +config+ object:

<ruby>
  config.active_record.timestamped_migrations = false
</ruby>

Rails will use that particular setting to configure Active Record.

h4. Rails General Configuration

* +config.cache_classes+ controls whether or not application classes should be reloaded on each request. Defaults to _true_ in development, _false_ in test and production.

* +config.cache_store+ configures which cache store to use for Rails caching. Options include +:memory_store+, +:file_store+, +:mem_cache_store+ or the name of your own custom class.

{'fraction_non_alphanumeric': 0.055350553505535055, 'fraction_numerical': 0.0036900369003690036, 'mean_word_length': 5.072, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1678940', 'n_tokens_mistral': 983, 'n_tokens_neox': 930, 'n_words': 495}