vinistock / sail

Sail is a lightweight Rails engine that brings an admin panel for managing configuration settings on a live Rails app
Other
508 stars 32 forks source link

Load new (partial) settings #210

Closed sandipagarwal closed 4 years ago

vinistock commented 4 years ago

Hi, @sandipagarwal! Thank you for your contribution. Could you please explain the reasoning and use case behind this new rake task?

Invoking Setting.load_defaults(false) will not update the values for any settings. It will solely create new/destroy settings that have been added/removed from the sail.yml file. However, this already happens during boot time in a Sail initializer, so I'm not sure when this task would be used.

If you updated the contents of sail.yml and need to reflect it in the database, then you should use rake sail:load_defaults, which will re-create all settings with the new configurations.

sandipagarwal commented 4 years ago

Hi, @sandipagarwal! Thank you for your contribution. Could you please explain the reasoning and use case behind this new rake task?

Invoking Setting.load_defaults(false) will not update the values for any settings. It will solely create new/destroy settings that have been added/removed from the sail.yml file. However, this already happens during boot time in a Sail initializer, so I'm not sure when this task would be used.

If you updated the contents of sail.yml and need to reflect it in the database, then you should use rake sail:load_defaults, which will re-create all settings with the new configurations.

Hi @vinistock, I understand the settings are reflected at boot time, but as a dev, I want this to reflect w/o restarting my app/docker. Hence, this helps me fire a rake task that does the work for me.

vinistock commented 4 years ago

@sandipagarwal I'm having a hard time understanding the exact scenario in which you would need this.

When you invoke Setting.load_defaults(false), it will not update the values for settings. It compares the entries in config/sail.yml and the settings in the database. If new items were added in the file, they are created in the database. If items were removed from the file, they are removed from the database.

There are only two cases in which this rake task would actually do something (please help me understand exactly what you are doing in your app):

  1. The contents of config/sail.yml changed. If they have changed, that means you are deploying and the app is going to be rebooted anyway.
  2. Your main app is creating/destroying settings from the database. If this is the case, please explain why you need to do this.

And again, if you just need a full reset of your database you can invoke rake sail:load_defaults.