Rails: Settingslogic accessible to users?
I have my app configured with Settingslogic, which I love. My question is how to I make a page on my Rails app where Administrators can make changes to the settings specified in config/se开发者_运维技巧ttings.yml
??
I assume said page would have to read and display appropriate form fields for all the values in the YAML file, then save those values back to config/settings.yml
? Would those settings take effect immediately or would the server need to be restarted?
Bit lost here. Thanks.
Related: Rails application settings?
I couldn't figure this out, so I've switch from Settingslogic to rails-settings, which allows me to store settings equally easy in the database, which makes them far easier for me to set up editing by the end user.
If anyone figures this out with Settingslogic, I'd really love to hear a solution!
I think you were on the right path. What I'd do is to create some kind of fake model using ActiveModel that would allow you to create an easy form for modifying each individual setting. After the form is submitted simply write to the settingslogic source file by calling .to_yaml on your returned object.
Lastly, to reload your settings you can invoke Settings.reload! without having to restart the entire application.
I realize this is well after you asked your question, but thought I'd provide an answer in case others stumble upon it too.
精彩评论