golden-setting 0.5.0 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +14 -11
- data/app/controllers/golden/setting/settings_controller.rb +9 -5
- data/app/models/concerns/golden/setting/resourced.rb +1 -1
- data/app/views/golden/setting/settings/_batch_form.html.erb +8 -11
- data/app/views/golden/setting/settings/_form.html.erb +23 -25
- data/app/views/golden/setting/settings/edit.html.erb +26 -19
- data/app/views/golden/setting/settings/index.html.erb +23 -21
- data/app/views/golden/setting/settings/list.html.erb +13 -8
- data/app/views/golden/setting/settings/new.html.erb +23 -16
- data/app/views/golden/setting/settings/show.html.erb +15 -13
- data/config/locales/settings.en.yml +5 -0
- data/config/locales/settings.zh-TW.yml +5 -0
- data/lib/generators/golden/setting/USAGE +2 -2
- data/lib/generators/golden/setting/install_generator.rb +34 -10
- data/lib/generators/golden/setting/templates/golden_setting.rb +8 -0
- data/lib/golden/setting.rb +8 -0
- data/lib/golden/setting/base.rb +8 -0
- data/lib/golden/setting/version.rb +1 -1
- metadata +25 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f5ef7b0642fbe4c30a6150d682b2a9d0c9d451059907ca1e99bdbd51092f1659
|
4
|
+
data.tar.gz: 60ba763e1d9215bd7db4db0a215a91953b7290e0efdfb03681b9ab00d2077878
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 111ba2611a97cc1b18642ef24df9030b22f2c74128f8774cf668b946689432ed03d5f2b579d9fd1b1b5760f0ffd49145949d10dc715bedd91dede94fb7196712
|
7
|
+
data.tar.gz: b2b4274594f0fc5b261b41f2547e453967d19fbeade977bf1e8d19c8f8c4555fc47520218a4946000377a17c108f5c7cd96e2cf79cbd8bddee9e6348c56bd7ef
|
data/README.md
CHANGED
@@ -9,12 +9,12 @@ A web interface is provied to let users can update easily.
|
|
9
9
|
For Rails 4 project, `Gemfile` should have
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem 'devise', '
|
13
|
-
gem '
|
14
|
-
gem 'simple_form', '~> 3.0
|
15
|
-
gem '
|
12
|
+
gem 'devise', '~> 3.0'
|
13
|
+
gem 'cancancan'
|
14
|
+
gem 'simple_form', '~> 3.0'
|
15
|
+
gem 'bootstrap-sass'
|
16
16
|
gem 'will_paginate'
|
17
|
-
gem '
|
17
|
+
gem 'golden-theme'
|
18
18
|
```
|
19
19
|
|
20
20
|
If you add `gem 'protected_attributes'` in your `Gemfile`, remember to add
|
@@ -29,11 +29,11 @@ For Rails 3 project, `Gemfile` should have
|
|
29
29
|
|
30
30
|
```ruby
|
31
31
|
gem 'devise', '>= 2.0', '< 3.0'
|
32
|
-
gem '
|
32
|
+
gem 'cancancan'
|
33
33
|
gem 'simple_form', '>= 2.0', '< 3.0'
|
34
|
-
gem '
|
34
|
+
gem 'bootstrap-sass'
|
35
35
|
gem 'will_paginate'
|
36
|
-
gem '
|
36
|
+
gem 'golden-theme'
|
37
37
|
```
|
38
38
|
|
39
39
|
Please make sure these gems are installed and configured properly.
|
@@ -54,7 +54,7 @@ $ rails generate golden:setting:install setting
|
|
54
54
|
$ rake db:migrate
|
55
55
|
```
|
56
56
|
|
57
|
-
Remember add setting abilities for `
|
57
|
+
Remember add setting abilities for `cancancan`.
|
58
58
|
|
59
59
|
```ruby
|
60
60
|
can :index, Setting
|
@@ -68,6 +68,7 @@ You will need to add these basic configures of `golden-setting` for your needs.
|
|
68
68
|
* `groups` for grouping settings with a name
|
69
69
|
* `default_group` for saving settings with a group
|
70
70
|
* `default_tab` for a group of settings shown in tab views
|
71
|
+
* `before_actions` for setting up authentication filters
|
71
72
|
|
72
73
|
Edit `config/initializers/golden_setting.rb` for more detail.
|
73
74
|
|
@@ -137,7 +138,7 @@ You can add virtaul settings for your application by setting defaults.
|
|
137
138
|
Add `config/initializers/golden_setting_defaults.rb`.
|
138
139
|
|
139
140
|
```ruby
|
140
|
-
|
141
|
+
Rails.application.config.after_initialize do
|
141
142
|
Setting.defaults[:administrator] = 'tsechingho'
|
142
143
|
end
|
143
144
|
```
|
@@ -152,7 +153,7 @@ Setting.administrator # => 'tsechingho'
|
|
152
153
|
You can also save default settings in database after initializing your application.
|
153
154
|
|
154
155
|
```ruby
|
155
|
-
|
156
|
+
Rails.application.config.after_initialize do
|
156
157
|
Setting.save_default :manager, 'tsechingho'
|
157
158
|
end
|
158
159
|
```
|
@@ -165,6 +166,8 @@ Setting.object('manager').group # => 'site'
|
|
165
166
|
Setting.manager # => 'tsechingho'
|
166
167
|
```
|
167
168
|
|
169
|
+
For Rails 3 project, use `YourApp::Application.config.after_initialize` instead.
|
170
|
+
|
168
171
|
### Resourced settings
|
169
172
|
|
170
173
|
Settings may be bound to any existing ActiveRecord object.
|
@@ -1,5 +1,10 @@
|
|
1
1
|
class Golden::Setting::SettingsController < ApplicationController
|
2
|
-
|
2
|
+
if Golden::Setting.before_actions.blank?
|
3
|
+
raise "Please set config.before_actions like `authenticate_user!` for security."
|
4
|
+
end
|
5
|
+
Golden::Setting.before_actions.each do |action|
|
6
|
+
before_filter action.to_sym
|
7
|
+
end
|
3
8
|
before_filter :load_setting_class, only: [:index, :create, :list, :batch_update]
|
4
9
|
before_filter :new_setting, only: [:create]
|
5
10
|
load_and_authorize_resource :setting, class: Golden::Setting.setting_class, parent: false
|
@@ -47,7 +52,7 @@ class Golden::Setting::SettingsController < ApplicationController
|
|
47
52
|
def batch_update
|
48
53
|
params[:setting].each do |setting, value|
|
49
54
|
@setting_class.send "#{setting}=", value
|
50
|
-
end
|
55
|
+
end if params[:setting]
|
51
56
|
redirect_to action: :index
|
52
57
|
end
|
53
58
|
|
@@ -59,14 +64,13 @@ class Golden::Setting::SettingsController < ApplicationController
|
|
59
64
|
|
60
65
|
def new_setting
|
61
66
|
value = params[:setting].delete :value
|
62
|
-
@setting = @setting_class.new
|
67
|
+
@setting = @setting_class.new setting_params
|
63
68
|
@setting.value = value
|
64
69
|
end
|
65
70
|
|
66
71
|
def setting_params
|
67
72
|
if params.respond_to? :permit
|
68
|
-
|
69
|
-
params.require(:setting).permit(fields)
|
73
|
+
params.require(:setting).permit(Golden::Setting.permitted_fields)
|
70
74
|
else
|
71
75
|
params[:setting]
|
72
76
|
end
|
@@ -1,24 +1,21 @@
|
|
1
1
|
<%= simple_form_for setting_class,
|
2
2
|
as: :setting,
|
3
3
|
url: batch_update_settings_path,
|
4
|
-
method: :put
|
5
|
-
html: { class: 'form-horizontal' } do |f| %>
|
4
|
+
method: :put do |f| %>
|
6
5
|
|
7
6
|
<%= f.error_notification %>
|
8
7
|
|
9
8
|
<% settings.each do |setting| %>
|
10
9
|
<% next if skip_setting? setting.name %>
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
input_html: { value: setting.value } %>
|
18
|
-
</div>
|
10
|
+
<%= f.input setting.name,
|
11
|
+
as: setting.field_type,
|
12
|
+
collection: setting_field_values(setting.field_values),
|
13
|
+
label: setting_name(setting.name),
|
14
|
+
include_blank: false,
|
15
|
+
input_html: { value: setting.value } %>
|
19
16
|
<% end %>
|
20
17
|
|
21
18
|
<div class="form-actions">
|
22
|
-
<%=
|
19
|
+
<%= f.button :submit, t('.submit'), name: nil %>
|
23
20
|
</div>
|
24
21
|
<% end %>
|
@@ -1,25 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
} %>
|
25
|
-
</div>
|
1
|
+
<%= f.input :field_type,
|
2
|
+
as: :select,
|
3
|
+
collection: setting_field_types,
|
4
|
+
include_blank: false,
|
5
|
+
required: true %>
|
6
|
+
<%= f.input :field_values,
|
7
|
+
as: :text,
|
8
|
+
required: true,
|
9
|
+
wrapper_html: {
|
10
|
+
class: setting_selectable?(f.object.field_type) ? '' : 'hide'
|
11
|
+
} %>
|
12
|
+
<%= f.input :group,
|
13
|
+
as: :select,
|
14
|
+
collection: setting_groups,
|
15
|
+
include_blank: false %>
|
16
|
+
<%= f.input :name %>
|
17
|
+
<%= f.input :value,
|
18
|
+
as: f.object.field_type,
|
19
|
+
collection: setting_field_values(f.object.field_values),
|
20
|
+
include_blank: false,
|
21
|
+
input_html: {
|
22
|
+
value: f.object.value
|
23
|
+
} %>
|
@@ -3,26 +3,33 @@
|
|
3
3
|
<h1><%= t('.title') %></h1>
|
4
4
|
</header>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
<div class="tabbable">
|
7
|
+
<%= render_list class: 'nav nav-tabs' do |li|
|
8
|
+
if can? :index, @setting.class
|
9
|
+
li << [link_to(t('.index'), settings_path), { class: 'pull-right' }]
|
10
|
+
end
|
11
|
+
if can? :list, @setting.class
|
12
|
+
li << [link_to(t('.list'), list_settings_path), { class: 'pull-right' }]
|
13
|
+
end
|
14
|
+
if can? :show, @setting
|
15
|
+
li << [link_to(t('helpers.show'), setting_path(@setting)), { class: 'pull-right' }]
|
16
|
+
end
|
17
|
+
end %>
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
<%=
|
24
|
-
|
25
|
-
|
19
|
+
<div>
|
20
|
+
<%= simple_form_for @setting,
|
21
|
+
as: :setting,
|
22
|
+
url: setting_path(@setting) do |f| %>
|
23
|
+
|
24
|
+
<%= f.error_notification %>
|
25
|
+
|
26
|
+
<%= render 'form', f: f %>
|
27
|
+
|
28
|
+
<div class="form-actions">
|
29
|
+
<%= f.button :submit, name: nil %>
|
30
|
+
</div>
|
31
|
+
<% end %>
|
32
|
+
</div>
|
26
33
|
</div>
|
27
34
|
|
28
35
|
<footer>
|
@@ -3,29 +3,31 @@
|
|
3
3
|
<h1><%= t('.title') %></h1>
|
4
4
|
</header>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
6
|
+
<div class="tabbable">
|
7
|
+
<%= render_list class: 'nav nav-tabs' do |li|
|
8
|
+
if can? :new, @setting_class
|
9
|
+
li << [link_to(t('helpers.new'), new_setting_path), { class: 'pull-right' }]
|
10
|
+
end
|
11
|
+
if can? :list, @setting_class
|
12
|
+
li << [link_to(t('.list'), list_settings_path), { class: 'pull-right' }]
|
13
|
+
end
|
14
|
+
Golden::Setting.groups.each do |key, value|
|
15
|
+
next if skip_setting_group? key
|
16
|
+
li << settings_nav_tab(key, @default_tab)
|
17
|
+
end
|
18
|
+
end %>
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
<div class="tab-content">
|
21
|
+
<% Golden::Setting.groups.each do |key, value| %>
|
22
|
+
<% next if skip_setting_group? key %>
|
23
|
+
<%= settings_tab_pane key, @default_tab do %>
|
24
|
+
<%= render 'batch_form',
|
25
|
+
settings: @setting_class.without_resource.grouped(key),
|
26
|
+
setting_class: @setting_class
|
27
|
+
%>
|
28
|
+
<% end %>
|
27
29
|
<% end %>
|
28
|
-
|
30
|
+
</div>
|
29
31
|
</div>
|
30
32
|
|
31
33
|
<footer>
|
@@ -3,15 +3,20 @@
|
|
3
3
|
<h1><%= t('.title') %></h1>
|
4
4
|
</header>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
<div class="tabbable">
|
7
|
+
<%= render_list class: 'nav nav-tabs' do |li|
|
8
|
+
if can? :new, @setting_class
|
9
|
+
li << [link_to(t('helpers.new'), new_setting_path), { class: 'pull-right' }]
|
10
|
+
end
|
11
|
+
if can? :index, @setting_class
|
12
|
+
li << [link_to(t('.index'), settings_path), { class: 'pull-right' }]
|
13
|
+
end
|
14
|
+
end %>
|
11
15
|
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
<div>
|
17
|
+
<%= render 'table', settings: @settings, setting_class: @setting_class %>
|
18
|
+
<%= render 'application/pagination', collection: @settings %>
|
19
|
+
</div>
|
15
20
|
</div>
|
16
21
|
|
17
22
|
<footer>
|
@@ -3,23 +3,30 @@
|
|
3
3
|
<h1><%= t('.title') %></h1>
|
4
4
|
</header>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
<div class="tabbable">
|
7
|
+
<%= render_list class: 'nav nav-tabs' do |li|
|
8
|
+
if can? :index, @setting.class
|
9
|
+
li << [link_to(t('.index'), settings_path), { class: 'pull-right' }]
|
10
|
+
end
|
11
|
+
if can? :list, @setting.class
|
12
|
+
li << [link_to(t('.list'), list_settings_path), { class: 'pull-right' }]
|
13
|
+
end
|
14
|
+
end %>
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
<%=
|
21
|
-
|
22
|
-
|
16
|
+
<div>
|
17
|
+
<%= simple_form_for @setting,
|
18
|
+
as: :setting,
|
19
|
+
url: settings_path do |f| %>
|
20
|
+
|
21
|
+
<%= f.error_notification %>
|
22
|
+
|
23
|
+
<%= render 'form', f: f %>
|
24
|
+
|
25
|
+
<div class="form-actions">
|
26
|
+
<%= f.button :submit, name: nil %>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
29
|
+
</div>
|
23
30
|
</div>
|
24
31
|
|
25
32
|
<footer>
|
@@ -3,20 +3,22 @@
|
|
3
3
|
<h1><%= t('.title', name: @setting.name) %></h1>
|
4
4
|
</header>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
<div class="tabbable">
|
7
|
+
<%= render_list class: 'nav nav-tabs' do |li|
|
8
|
+
if can? :index, @setting.class
|
9
|
+
li << [link_to(t('.index'), settings_path), { class: 'pull-right' }]
|
10
|
+
end
|
11
|
+
if can? :list, @setting.class
|
12
|
+
li << [link_to(t('.list'), list_settings_path), { class: 'pull-right' }]
|
13
|
+
end
|
14
|
+
if can? :edit, @setting
|
15
|
+
li << [link_to(t('helpers.edit'), edit_setting_path(@setting)), { class: 'pull-right' }]
|
16
|
+
end
|
17
|
+
end %>
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
<div>
|
20
|
+
<%= render 'setting', setting: @setting %>
|
21
|
+
</div>
|
20
22
|
</div>
|
21
23
|
|
22
24
|
<footer>
|
@@ -10,14 +10,19 @@ en:
|
|
10
10
|
settings:
|
11
11
|
edit:
|
12
12
|
title: 'Editing setting'
|
13
|
+
index: 'Settings'
|
14
|
+
list: 'List'
|
13
15
|
index:
|
14
16
|
title: 'Settings'
|
15
17
|
list: 'List'
|
16
18
|
new:
|
17
19
|
title: 'New setting'
|
20
|
+
index: 'Settings'
|
18
21
|
list: 'List'
|
19
22
|
show:
|
20
23
|
title: 'Setting - %{name}'
|
24
|
+
index: 'Settings'
|
25
|
+
list: 'List'
|
21
26
|
list:
|
22
27
|
title: 'Listing settings'
|
23
28
|
index: 'Settings'
|
@@ -10,14 +10,19 @@ zh-TW:
|
|
10
10
|
settings:
|
11
11
|
edit:
|
12
12
|
title: '編輯設定'
|
13
|
+
index: '設定管理'
|
14
|
+
list: '設定列表'
|
13
15
|
index:
|
14
16
|
title: '設定管理'
|
15
17
|
list: '設定列表'
|
16
18
|
new:
|
17
19
|
title: '新增設定'
|
20
|
+
index: '設定管理'
|
18
21
|
list: '設定列表'
|
19
22
|
show:
|
20
23
|
title: '設定 - %{name}'
|
24
|
+
index: '設定管理'
|
25
|
+
list: '設定列表'
|
21
26
|
list:
|
22
27
|
title: '設定列表'
|
23
28
|
index: '設定管理'
|
@@ -7,8 +7,8 @@ Example:
|
|
7
7
|
This will create/modify:
|
8
8
|
db/migrate/20130516050309_create_golden_settings.rb
|
9
9
|
app/models/setting.rb
|
10
|
-
app/assets/javascripts/application.js
|
11
|
-
app/assets/stylesheets/application.css
|
10
|
+
app/assets/javascripts/application.js(.coffee)
|
11
|
+
app/assets/stylesheets/application.css(.sass|.scss)
|
12
12
|
config/initializers/golden_setting.rb
|
13
13
|
config/application.rb
|
14
14
|
config/locales/golden/settings.en.yml
|
@@ -24,8 +24,9 @@ class Golden::Setting::InstallGenerator < Rails::Generators::NamedBase
|
|
24
24
|
template file, File.join('app/models', class_path, "#{file_name}.rb"), verbose: false
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def inject_javascript_js
|
28
28
|
file = 'app/assets/javascripts/application.js'
|
29
|
+
return unless File.exists? file
|
29
30
|
log :javascripts, 'application.js'
|
30
31
|
sentinel = "//= require_tree .\n"
|
31
32
|
insert_into_file file, before: sentinel, verbose: false do
|
@@ -33,8 +34,19 @@ class Golden::Setting::InstallGenerator < Rails::Generators::NamedBase
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
|
-
def
|
37
|
+
def inject_javascript_coffee
|
38
|
+
file = 'app/assets/javascripts/application.js.coffee'
|
39
|
+
return unless File.exists? file
|
40
|
+
log :javascripts, 'application.js.coffee'
|
41
|
+
sentinel = "#= require_tree .\n"
|
42
|
+
insert_into_file file, before: sentinel, verbose: false do
|
43
|
+
"#= require golden/setting/settings\n"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def inject_stylesheet_css
|
37
48
|
file = 'app/assets/stylesheets/application.css'
|
49
|
+
return unless File.exists? file
|
38
50
|
log :stylesheets, 'application.css'
|
39
51
|
sentinel = " *= require_self\n"
|
40
52
|
insert_into_file file, before: sentinel, verbose: false do
|
@@ -42,6 +54,26 @@ class Golden::Setting::InstallGenerator < Rails::Generators::NamedBase
|
|
42
54
|
end
|
43
55
|
end
|
44
56
|
|
57
|
+
def inject_stylesheet_sass
|
58
|
+
file = 'app/assets/stylesheets/application.css.sass'
|
59
|
+
return unless File.exists? file
|
60
|
+
log :stylesheets, 'application.css.sass'
|
61
|
+
sentinel = "//= require_self\n"
|
62
|
+
insert_into_file file, before: sentinel, verbose: false do
|
63
|
+
"//= require golden/setting/settings\n"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def inject_stylesheet_scss
|
68
|
+
file = 'app/assets/stylesheets/application.css.scss'
|
69
|
+
return unless File.exists? file
|
70
|
+
log :stylesheets, 'application.css.scss'
|
71
|
+
sentinel = "//= require_self\n"
|
72
|
+
insert_into_file file, before: sentinel, verbose: false do
|
73
|
+
"//= require golden/setting/settings\n"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
45
77
|
def generate_initializer
|
46
78
|
file = 'golden_setting.rb'
|
47
79
|
log :initializer, file
|
@@ -68,14 +100,6 @@ class Golden::Setting::InstallGenerator < Rails::Generators::NamedBase
|
|
68
100
|
route "mount Golden::Setting::Engine, at: '/'\n"
|
69
101
|
end
|
70
102
|
|
71
|
-
def inject_controller
|
72
|
-
file = 'app/controllers/application_controller.rb'
|
73
|
-
sentinel = "protect_from_forgery with: :exception\n"
|
74
|
-
insert_into_file file, after: sentinel do
|
75
|
-
" alias_method :authenticate_session!, :authenticate_user!\n"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
103
|
def inject_layout
|
80
104
|
file = 'app/views/layouts/application.html.erb'
|
81
105
|
sentinel = "<%= yield %>\n"
|
@@ -33,4 +33,12 @@ Golden::Setting.configure do |config|
|
|
33
33
|
# Define default tab with name of groups.
|
34
34
|
# Default is ''.
|
35
35
|
config.default_tab = 'site'
|
36
|
+
|
37
|
+
# Add more allowed fields for strong paramters.
|
38
|
+
#config.permitted_fields += []
|
39
|
+
|
40
|
+
# Define before_actions.
|
41
|
+
config.before_actions += [
|
42
|
+
'authenticate_user!'
|
43
|
+
]
|
36
44
|
end
|
data/lib/golden/setting.rb
CHANGED
@@ -35,6 +35,14 @@ module Golden
|
|
35
35
|
mattr_accessor :default_tab
|
36
36
|
@@default_tab = ''
|
37
37
|
|
38
|
+
mattr_accessor :permitted_fields
|
39
|
+
@@permitted_fields = [
|
40
|
+
:field_type, :field_values, :group, :name, :value
|
41
|
+
]
|
42
|
+
|
43
|
+
mattr_accessor :before_actions
|
44
|
+
@@before_actions = []
|
45
|
+
|
38
46
|
def self.configure
|
39
47
|
yield self
|
40
48
|
end
|
data/lib/golden/setting/base.rb
CHANGED
@@ -23,6 +23,14 @@ module Golden
|
|
23
23
|
without_resource.select(fields)
|
24
24
|
end
|
25
25
|
|
26
|
+
# For SimpleForm#find_attribute_column
|
27
|
+
def has_attribute? name
|
28
|
+
named(name).exists?
|
29
|
+
end
|
30
|
+
|
31
|
+
# For SimpleForm#find_attribute_column
|
32
|
+
# def type_for_attribute name; end
|
33
|
+
|
26
34
|
def method_missing method, *args
|
27
35
|
super method, *args
|
28
36
|
rescue NoMethodError
|
metadata
CHANGED
@@ -1,109 +1,109 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: golden-setting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tse-Ching Ho
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.13
|
20
|
-
- - <
|
20
|
+
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '5'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.2.13
|
30
|
-
- - <
|
30
|
+
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '5'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: railties
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: 3.2.13
|
40
|
-
- - <
|
40
|
+
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '5'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: 3.2.13
|
50
|
-
- - <
|
50
|
+
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '5'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: bundler
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - ~>
|
57
|
+
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '1.3'
|
60
60
|
type: :development
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - ~>
|
64
|
+
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '1.3'
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: rake
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
- -
|
71
|
+
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
74
|
type: :development
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- -
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rspec
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- -
|
85
|
+
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: 2.13.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- -
|
92
|
+
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: 2.13.0
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: sqlite3
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- -
|
106
|
+
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
description: Golden Setting persists settings in database and keep alive in cache.
|
@@ -113,7 +113,7 @@ executables: []
|
|
113
113
|
extensions: []
|
114
114
|
extra_rdoc_files: []
|
115
115
|
files:
|
116
|
-
- .gitignore
|
116
|
+
- ".gitignore"
|
117
117
|
- Gemfile
|
118
118
|
- LICENSE.txt
|
119
119
|
- README.md
|
@@ -165,24 +165,23 @@ homepage: https://github.com/goldenio/golden-setting
|
|
165
165
|
licenses:
|
166
166
|
- MIT
|
167
167
|
metadata: {}
|
168
|
-
post_install_message:
|
168
|
+
post_install_message:
|
169
169
|
rdoc_options: []
|
170
170
|
require_paths:
|
171
171
|
- lib
|
172
172
|
required_ruby_version: !ruby/object:Gem::Requirement
|
173
173
|
requirements:
|
174
|
-
- -
|
174
|
+
- - ">="
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '0'
|
177
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
178
|
requirements:
|
179
|
-
- -
|
179
|
+
- - ">="
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
|
-
|
184
|
-
|
185
|
-
signing_key:
|
183
|
+
rubygems_version: 3.2.3
|
184
|
+
signing_key:
|
186
185
|
specification_version: 4
|
187
186
|
summary: persists settings in database and keep alive in cache.
|
188
187
|
test_files:
|