# Discourse Plugins and Rails 6 config/initializers Question

**URL:** <https://meta.discourse.org/t/discourse-plugins-and-rails-6-config-initializers-question/168373>\
**Category:** Development\
**Created:** [October 27, 2020, 11:34am UTC](https://meta.discourse.org/t/discourse-plugins-and-rails-6-config-initializers-question/168373 "2020-10-27T11:34:52Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)\
**Post date:** [November 4, 2020, 10:35am UTC](https://meta.discourse.org/t/discourse-plugins-and-rails-6-config-initializers-question/168373/21 "2020-11-04T10:35:25Z")

</div>

> [@markvanlan](#):
>
> Anything inside the `after_initialize` block of plugin.rb is only loaded [during application boot](https://github.com/discourse/discourse/blob/5140ec9acf29df220ec00cc6a704b73773a86bdc/config/application.rb#L342-L342), and not on subsequent reloads.

This is describing a core Rails property, which is not germane to Discourse.

In Rails, all initializers are loaded only when Rails starts up, so any plugin which executes code based on the initializer, like “after\_initializer” will only execute on Rails start up or restart (please correct me if wrong).

> **[Ruby on Rails Guides: Configuring Rails Applications](https://guides.rubyonrails.org/v2.3/configuring.html)**

The reason I am familiar with this is that I am currently building a Rails application for a client and I have written a lot of initializers for various tasks (booleans, static arrays, etc). In each case, if we change any code in a Rails initializer, it is necessary to restart Rails (“Control c, rails s in dev”) to get the new values in the initializers into the Rails app.

Please correct me if I am wrong! Thanks.

Sometimes, I think it might be a bit confusing to some Discourse plugin developers, especially those developers who primarily work on Discourse plugins and not with Rails applications in general, when we write “Discourse does this” or “Discourse does that” when what we are really describing is a core Rails function or property not necessarily germane to Discourse, per se.

Rails 6 reads all files in the `config/initializers` directory (and all `config/initializers` subdirectories) **only** when Rails starts up. Likewise (not 100% sure about plugins) a Discourse plugin with code dependent on `after_initialize` will (kindly confirm anyone?) only be loaded by the Rails app when Rails starts up or restarts, because this is a fundamental property of the Rails boot process.

My guess is that everyone here already knows this who works on Rails. I only am starting to know these details (and feel I have a long way to go to be an expert); because I’m currently working on a Rails application every day (these days), which by-the-way, I now wish I would have starting working with Rails a decade ago because coming from a LAMP dev background, I find Rails so very much better (easy and fun to work with).

I have become a major Rails fan this year and I am very grateful to Discourse to starting me down that path.

Again, please correct me if I am wrong! Thanks. I’m trying to be more expert in Rails.

---

_[View the full topic](https://meta.discourse.org/t/discourse-plugins-and-rails-6-config-initializers-question/168373)._
