Comments (4)
Ok, so i've tested a bit more and i am getting a little bit confused.
As i said earlier, before the update i had a default_settings initializer, where values were defined like this:
Setting.defaults['some.nested.key'] = "value"
I had to change this to use app.yml, where i have defined it like so:
some:
nested:
key: value
I didn't change my settings controller logic (updating values), and in the views for example i am accesing this value like before the update: user.settings["some.nested.key"]
. Updating this value is done the same way user.settings["some.nested.key"] = "updated value"
.
Now, when i go to console i have two different values:
Setting["some.nested.key"] = "value"
user.setting["some.nested.key"] = "updated value"
Quite logical i would say. But what i don't understand is the get_all behaviour which returns both keys!
user.settings.get_all:
{ "some.nested.key" => "updated value",
some => { nested => { key: "value" } }
}
from rails-settings-cached.
I think the problem is in how key/value should be saved in the database.
Please, can someone help me understand, how key should be saved in the database, so that it is then read by the get_all as yaml?
For example, if i update simple first level key of "something", it will then be read from DB and shown inside get_all hash (taking precedence to yaml config value).
But as soon as I have multilevel values, they are saved in the DB in a wrong format (i think) and hash than returns both values (DB and YAML). DB value is flat "nested.key" and config value is in a hash format.
How do i save multilevel settings in the database so that get_all will return only DB value if exists, and if not a config value?
Thx
from rails-settings-cached.
OK, I see now that settings can't be actually saved in nested way, so it should just be flat definitions
from rails-settings-cached.
@Svashta Yes, in currently rails-settings-cached has not supported with nested key:
from rails-settings-cached.
Related Issues (20)
- Usage in i18n config files HOT 1
- Readme Typo
- ๐จ in "_table_exists?" the error rescuing is too generic.
- ๐จ fix for "_table_exists?" method HOT 4
- Support for metadata for fields HOT 1
- Default Proc setting does not work if it is readonly
- getting an undefined method for a setting HOT 6
- Unable to use AR scope functionality HOT 3
- Consider document ActiveRecord::Store as another alternative to Scoped Settings
- Disable RequestCache without Rails application HOT 2
- Caching is buggy in Rails 5 HOT 3
- ไป่ฎพ็ฝฎๅๅพๅผๅๆฟๅฐ็ไธไธ่ด HOT 2
- Configurable Cache Expiration HOT 1
- Rails 6.1.6.1 no longer loading Settings in /config/environments/*.rb HOT 1
- Field of Type Hash
- Updating a value doesn't invalidate cache in distributed system HOT 3
- Configurable cache storage feature HOT 3
- Version 2.9.0 breaks `type: :date_time` HOT 3
- Change in behavior for integer HOT 1
- ActiveAdmin interface for v2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rails-settings-cached.