rails-settings-cached 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -4
- data/lib/generators/settings/templates/model.rb +1 -0
- data/lib/rails-settings/cached_settings.rb +6 -0
- metadata +3 -3
data/README.md
CHANGED
@@ -87,18 +87,28 @@ Setting.all('preferences.')
|
|
87
87
|
```
|
88
88
|
|
89
89
|
Set defaults for certain settings of your app. This will cause the defined settings to return with the
|
90
|
-
Specified value even if they are not in the database
|
90
|
+
Specified value even if they are **not in the database**. Make a new file in `config/initializers/default_settings.rb`
|
91
91
|
with the following:
|
92
92
|
|
93
93
|
```ruby
|
94
94
|
Setting.defaults[:some_setting] = 'footastic'
|
95
|
+
Setting.where(:var => "some_setting").count
|
96
|
+
=> 0
|
97
|
+
Setting.some_setting
|
98
|
+
=> "footastic"
|
95
99
|
```
|
96
|
-
|
97
|
-
|
100
|
+
|
101
|
+
Init defualt value in database, this has indifferent with `Setting.defaults[:some_setting]`, this will **save the value into database**:
|
98
102
|
|
99
103
|
```ruby
|
100
|
-
Setting.
|
104
|
+
Setting.save_default(:some_key) = "123"
|
105
|
+
Setting.where(:var => "some_key").count
|
106
|
+
=> 1
|
107
|
+
Setting.some_key
|
108
|
+
=> "123"
|
101
109
|
```
|
110
|
+
|
111
|
+
|
102
112
|
|
103
113
|
Settings may be bound to any existing ActiveRecord object. Define this association like this:
|
104
114
|
Notice! is not do caching in this version.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-settings-cached
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -16,7 +16,7 @@ date: 2012-11-26 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
19
|
-
requirement: &
|
19
|
+
requirement: &70117799454600 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ! '>='
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
version: 3.0.0
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *70117799454600
|
28
28
|
description:
|
29
29
|
email: huacnlee@gmail.com
|
30
30
|
executables: []
|