Rails initializers are called when the rails console starts.

I want to put my charging conf inside the initializer, but I found that the initializer will not run on my c rails, is there a way to call my initializers so that I can test in my console?

Chargify.configure do |c| c.api_key = "0JEg9MrZEAqfEB7srvz0wH9q600dSxlUkM7DB7DnG8c" c.subdomain = "test-site" end 
+5
source share
2 answers

Yes, every .rb file in config/initializers runs whenever you launch the console, run the rake command, or run your tests. In addition, the environment configuration ( config/environments ) is started before the initializers.

+3
source

config/initializers will be executed, but only once, at boot time. Therefore, if you make changes to config/initializers while the console is running, you will not see the results of these changes.

Your best option is to stop and restart rails c

Also, if you use spring, which sometimes prevents reloading of modified initializers. in this case, do spring stop before restarting the console.

+3
source

All Articles