huacnlee / rails-settings-cached

Global settings for your Rails application.
Other
1.06k stars 202 forks source link

Setting.<key> only returns default value when called in initializer #127

Closed ditsara closed 6 years ago

ditsara commented 7 years ago

When calling Setting. within an initializer, it only returns the default value (set in app.yml). However, Setting.get_all does contain the value from the database.

Could this be because the initializer where I'm calling Setting is evaluated before initializer 'rails_settings.active_record.initialization'?

EDIT: Just to be clear, the workaround I've found is to call Setting.get_all['<key>'], but I'm not sure why that works and Setting.<key> doesn't.

FX-HAO commented 6 years ago

I have the same issue. Did you fix it?

senghoo commented 6 years ago

same problem here.

jvoss commented 6 years ago

I have the same issue.

However, using Setting.get_all[''] is not viable solution for me as we need to have a default in the app.yml that can be overwritten and used by the initializer if it is.