How to implement a singleton model

后端 未结 13 1413
余生分开走
余生分开走 2020-12-24 12:36

I have a site in rails and want to have site-wide settings. One part of my app can notify the admin by SMS if a specific event happens. This is an example of a feature that

13条回答
  •  臣服心动
    2020-12-24 12:47

    I disagree with common opinion - there is nothing wrong with reading a property out of the database. You can read the database value and freeze if you'd like, however there could be more flexible alternatives to simple freezing.

    How is YAML different from database? .. same drill - external to application code persistent setting.

    Nice thing about the database approach is that it can be changed on the fly in more or less secure way (not opening and overwriting files directly). Another nice thing is it can be shared across the network between cluster nodes (if properly implemented).

    The question however remains what would be the proper way to implement such a setting using ActiveRecord.

提交回复
热议问题