rails_admin 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails_admin might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b602512e6e725b80b4710d009beb60fffc8089f20a677579174f5af05ed7a728
4
- data.tar.gz: b983654e17ee5f1a15bab17d2d5afbba7f06eb7d8b6f4be92112f5e9ad41ddf7
3
+ metadata.gz: 6580d80d2b5212de63e6324b4a11ce681fff331b44c443496e97ba42bdde7dfd
4
+ data.tar.gz: 3e5a0a86e8925d046fdc04ff6271fae2a04bceb88d745912da09a9b2fac9e32e
5
5
  SHA512:
6
- metadata.gz: d2ec664fd9c217fd62d3ca65af5718e095f8de4ac3919ea0fe29b2e8d203e984583dd11877aa1ff8c40e2e8a696e55f304f24312da87da08051ba0a2bc33c99a
7
- data.tar.gz: d2350c08e53ba3ed67e65bdd75863f4fd02b7c26ace2fdcafae81363b6567d6c5db52bcb2631224d0f5d291e46a9e577187fdcdc4bbc6e96613083dd8266b948
6
+ metadata.gz: def3648da6a0cdea8194b363f00f0a667cf44561b90d0a7f6afefd2b970db293e712fc34d5fc632402078b338e981409b034d3a7bde5c22c049a55a34587d469
7
+ data.tar.gz: a5a101d26309d3a77d0f6f56375914ac914833a677bc3d5689229a5bf7d9ad662572c8ddda10d5dcad9fe827a30c7556e143e5022a1d38d821eb755ceb8ae3eb
data/Gemfile CHANGED
@@ -21,24 +21,22 @@ end
21
21
  group :test do
22
22
  gem 'cancancan', '~> 3.0'
23
23
  gem 'carrierwave', ['>= 2.0.0.rc', '< 3']
24
- gem 'coveralls'
25
- gem 'database_cleaner', ['>= 1.2', '!= 1.4.0', '!= 1.5.0']
24
+ gem 'database_cleaner', ['>= 1.2', '!= 1.4.0', '!= 1.5.0', '< 2.0']
26
25
  gem 'dragonfly', '~> 1.0'
27
26
  gem 'factory_bot', '>= 4.2'
28
27
  gem 'generator_spec', '>= 0.8'
29
28
  gem 'launchy', '>= 2.2'
30
29
  gem 'mini_magick', '>= 3.4'
31
- gem 'paperclip', ['>= 3.4', '!= 4.3.0']
32
30
  gem 'poltergeist', '~> 1.5'
33
31
  gem 'pundit'
34
32
  gem 'rack-cache', require: 'rack/cache'
35
33
  gem 'rspec-rails', '>= 2.14'
36
34
  gem 'rspec-expectations', '!= 3.8.3'
37
- gem 'rubocop', '~> 0.68.1'
38
- gem 'rubocop-performance'
35
+ gem 'rspec-retry'
36
+ gem 'rubocop', '~> 0.68.1', require: false
37
+ gem 'rubocop-performance', require: false
39
38
  gem 'simplecov', '>= 0.9', require: false
40
- gem 'shrine', '~> 2.0'
41
- gem 'shrine-memory'
39
+ gem 'simplecov-lcov', require: false
42
40
  gem 'timecop', '>= 0.5'
43
41
 
44
42
  platforms :ruby_19 do
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # RailsAdmin
2
2
 
3
3
  [![Gem Version](https://img.shields.io/gem/v/rails_admin.svg)][gem]
4
- [![Build Status](https://img.shields.io/travis/sferik/rails_admin.svg)][travis]
4
+ [![Build Status](https://img.shields.io/github/workflow/status/sferik/rails_admin/Test)][ghactions]
5
5
  [![Coverage Status](https://img.shields.io/coveralls/sferik/rails_admin.svg)][coveralls]
6
6
  [![Inline docs](http://inch-ci.org/github/sferik/rails_admin.svg)][inch]
7
7
  [![Code Climate](https://codeclimate.com/github/sferik/rails_admin.svg)][codeclimate]
8
8
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=rails_admin&package-manager=bundler&version-scheme=semver)][semver]
9
9
 
10
10
  [gem]: https://rubygems.org/gems/rails_admin
11
- [travis]: https://travis-ci.org/sferik/rails_admin
11
+ [ghactions]: https://github.com/sferik/rails_admin/actions
12
12
  [coveralls]: https://coveralls.io/r/sferik/rails_admin
13
13
  [inch]: http://inch-ci.org/github/sferik/rails_admin
14
14
  [codeclimate]: https://codeclimate.com/github/sferik/rails_admin
@@ -92,7 +92,7 @@ list][list].
92
92
  If you think you found a bug in RailsAdmin, you can [submit an issue](https://github.com/sferik/rails_admin/issues/new).
93
93
 
94
94
  ## Supported Ruby Versions
95
- This library aims to support and is [tested against][travis] the following Ruby implementations:
95
+ This library aims to support and is [tested against][ghactions] the following Ruby implementations:
96
96
 
97
97
  * Ruby 2.2
98
98
  * Ruby 2.3
@@ -100,6 +100,7 @@ This library aims to support and is [tested against][travis] the following Ruby
100
100
  * Ruby 2.5
101
101
  * Ruby 2.6
102
102
  * Ruby 2.7
103
+ * Ruby 3.0
103
104
  * [JRuby][]
104
105
 
105
106
  [jruby]: http://jruby.org/
@@ -11,6 +11,7 @@
11
11
  var field_value = options['value'];
12
12
  var field_operator = options['operator'];
13
13
  var select_options = options['select_options'];
14
+ var required = options['required'];
14
15
  var index = options['index'];
15
16
  var value_name = 'f[' + field_name + '][' + index + '][v]';
16
17
  var operator_name = 'f[' + field_name + '][' + index + '][o]';
@@ -24,9 +25,13 @@
24
25
  .append('<option value="_discard">...</option>')
25
26
  .append($('<option value="true"></option>').prop('selected', field_value == "true").text(RailsAdmin.I18n.t("true")))
26
27
  .append($('<option value="false"></option>').prop('selected', field_value == "false").text(RailsAdmin.I18n.t("false")))
27
- .append('<option disabled="disabled">---------</option>')
28
- .append($('<option value="_present"></option>').prop('selected', field_value == "_present").text(RailsAdmin.I18n.t("is_present")))
29
- .append($('<option value="_blank"></option>').prop('selected', field_value == "_blank").text(RailsAdmin.I18n.t("is_blank")));
28
+ if (!required) {
29
+ control.append([
30
+ '<option disabled="disabled">---------</option>',
31
+ $('<option value="_present"></option>').prop('selected', field_value == "_present").text(RailsAdmin.I18n.t("is_present")),
32
+ $('<option value="_blank"></option>').prop('selected', field_value == "_blank").text(RailsAdmin.I18n.t("is_blank"))
33
+ ])
34
+ }
30
35
  break;
31
36
  case 'date':
32
37
  additional_control =
@@ -56,9 +61,13 @@
56
61
  .append($('<option value="yesterday"></option>').prop('selected', field_operator == "yesterday").text(RailsAdmin.I18n.t("yesterday")))
57
62
  .append($('<option value="this_week"></option>').prop('selected', field_operator == "this_week").text(RailsAdmin.I18n.t("this_week")))
58
63
  .append($('<option value="last_week"></option>').prop('selected', field_operator == "last_week").text(RailsAdmin.I18n.t("last_week")))
59
- .append('<option disabled="disabled">---------</option>')
60
- .append($('<option value="_not_null"></option>').prop('selected', field_operator == "_not_null").text(RailsAdmin.I18n.t("is_present")))
61
- .append($('<option value="_null"></option>').prop('selected', field_operator == "_null").text(RailsAdmin.I18n.t("is_blank")));
64
+ if (!required) {
65
+ control.append([
66
+ '<option disabled="disabled">---------</option>',
67
+ $('<option value="_not_null"></option>').prop('selected', field_operator == "_not_null").text(RailsAdmin.I18n.t("is_present")),
68
+ $('<option value="_null"></option>').prop('selected', field_operator == "_null").text(RailsAdmin.I18n.t("is_blank"))
69
+ ])
70
+ }
62
71
  additional_control = additional_control ||
63
72
  $('<input size="25" class="datetime additional-fieldset default input-sm form-control" type="text" />')
64
73
  .css('display', (!field_operator || field_operator == "default") ? 'inline-block' : 'none')
@@ -84,10 +93,14 @@
84
93
  .prop('name', multiple_values ? undefined : value_name)
85
94
  .data('name', value_name)
86
95
  .append('<option value="_discard">...</option>')
87
- .append($('<option value="_present"></option>').prop('selected', field_value == "_present").text(RailsAdmin.I18n.t("is_present")))
88
- .append($('<option value="_blank"></option>').prop('selected', field_value == "_blank").text(RailsAdmin.I18n.t("is_blank")))
89
- .append('<option disabled="disabled">---------</option>')
90
- .append(select_options)
96
+ if (!required) {
97
+ control.append([
98
+ $('<option value="_present"></option>').prop('selected', field_value == "_present").text(RailsAdmin.I18n.t("is_present")),
99
+ $('<option value="_blank"></option>').prop('selected', field_value == "_blank").text(RailsAdmin.I18n.t("is_blank")),
100
+ '<option disabled="disabled">---------</option>'
101
+ ])
102
+ }
103
+ control.append(select_options)
91
104
  .add(
92
105
  $('<select multiple="multiple" class="select-multiple input-sm form-control"></select>')
93
106
  .css('display', multiple_values ? 'inline-block' : 'none')
@@ -111,9 +124,13 @@
111
124
  .append($('<option data-additional-fieldset="additional-fieldset" value="is"></option>').prop('selected', field_operator == "is").text(RailsAdmin.I18n.t("is_exactly")))
112
125
  .append($('<option data-additional-fieldset="additional-fieldset" value="starts_with"></option>').prop('selected', field_operator == "starts_with").text(RailsAdmin.I18n.t("starts_with")))
113
126
  .append($('<option data-additional-fieldset="additional-fieldset" value="ends_with"></option>').prop('selected', field_operator == "ends_with").text(RailsAdmin.I18n.t("ends_with")))
114
- .append('<option disabled="disabled">---------</option>')
115
- .append($('<option value="_present"></option>').prop('selected', field_operator == "_present").text(RailsAdmin.I18n.t("is_present")))
116
- .append($('<option value="_blank"></option>').prop('selected', field_operator == "_blank").text(RailsAdmin.I18n.t("is_blank")));
127
+ if (!required) {
128
+ control.append([
129
+ '<option disabled="disabled">---------</option>',
130
+ $('<option value="_present"></option>').prop('selected', field_operator == "_present").text(RailsAdmin.I18n.t("is_present")),
131
+ $('<option value="_blank"></option>').prop('selected', field_operator == "_blank").text(RailsAdmin.I18n.t("is_blank"))
132
+ ])
133
+ }
117
134
  additional_control = $('<input class="additional-fieldset input-sm form-control" type="text" />')
118
135
  .css('display', field_operator == "_present" || field_operator == "_blank" ? 'none' : 'inline-block')
119
136
  .prop('name', value_name)
@@ -126,9 +143,13 @@
126
143
  .prop('name', operator_name)
127
144
  .append($('<option data-additional-fieldset="default" value="default"></option>').prop('selected', field_operator == "default").text(RailsAdmin.I18n.t("number")))
128
145
  .append($('<option data-additional-fieldset="between" value="between"></option>').prop('selected', field_operator == "between").text(RailsAdmin.I18n.t("between_and_")))
129
- .append('<option disabled="disabled">---------</option>')
130
- .append($('<option value="_not_null"></option>').prop('selected', field_operator == "_not_null").text(RailsAdmin.I18n.t("is_present")))
131
- .append($('<option value="_null"></option>').prop('selected', field_operator == "_null").text(RailsAdmin.I18n.t("is_blank")));
146
+ if (!required) {
147
+ control.append([
148
+ '<option disabled="disabled">---------</option>',
149
+ $('<option value="_not_null"></option>').prop('selected', field_operator == "_not_null").text(RailsAdmin.I18n.t("is_present")),
150
+ $('<option value="_null"></option>').prop('selected', field_operator == "_null").text(RailsAdmin.I18n.t("is_blank"))
151
+ ])
152
+ }
132
153
  additional_control =
133
154
  $('<input class="additional-fieldset default input-sm form-control" type="text" />')
134
155
  .css('display', (!field_operator || field_operator == "default") ? 'inline-block' : 'none')
@@ -193,6 +214,7 @@
193
214
  value: $(this).data('field-value'),
194
215
  operator: $(this).data('field-operator'),
195
216
  select_options: $(this).data('field-options'),
217
+ required: $(this).data('field-required'),
196
218
  index: $.now().toString().slice(6,11),
197
219
  datetimepicker_format: $(this).data('field-datetimepicker-format')
198
220
  });
@@ -19,13 +19,13 @@
19
19
  sortable: false,
20
20
  removable: true,
21
21
  regional: {
22
- up: "Up",
23
- down: "Down",
24
- add: "Add",
25
- chooseAll: "Choose all",
26
- chosen: "Chosen records",
27
- clearAll: "Clear all",
28
- remove: "Remove"
22
+ add: 'Add',
23
+ chooseAll: 'Choose all',
24
+ clearAll: 'Clear all',
25
+ down: 'Down',
26
+ remove: 'Remove',
27
+ search: 'Search',
28
+ up: 'Up'
29
29
  },
30
30
  searchDelay: 400,
31
31
  remote_source: null,
@@ -38,16 +38,15 @@ module RailsAdmin
38
38
  end
39
39
 
40
40
  def field_wrapper_for(field, nested_in)
41
- if field.label
42
- # do not show nested field if the target is the origin
43
- unless nested_field_association?(field, nested_in)
44
- @template.content_tag(:div, class: "form-group control-group #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", id: "#{dom_id(field)}_field") do
45
- label(field.method_name, capitalize_first_letter(field.label), class: 'col-sm-2 control-label') +
46
- (field.nested_form ? field_for(field) : input_for(field))
47
- end
41
+ # do not show nested field if the target is the origin
42
+ return if nested_field_association?(field, nested_in)
43
+ @template.content_tag(:div, class: "form-group control-group #{field.type_css_class} #{field.css_class} #{'error' if field.errors.present?}", id: "#{dom_id(field)}_field") do
44
+ if field.label
45
+ label(field.method_name, capitalize_first_letter(field.label), class: 'col-sm-2 control-label') +
46
+ (field.nested_form ? field_for(field) : input_for(field))
47
+ else
48
+ field.nested_form ? field_for(field) : input_for(field)
48
49
  end
49
- else
50
- field.nested_form ? field_for(field) : input_for(field)
51
50
  end
52
51
  end
53
52
 
@@ -76,7 +76,8 @@ module RailsAdmin
76
76
  options[:type] = field.type
77
77
  options[:value] = filter_hash['v']
78
78
  options[:label] = field.label
79
- options[:operator] = filter_hash['o']
79
+ options[:operator] = filter_hash['o'] || field.default_filter_operator
80
+ options[:required] = field.required
80
81
  options
81
82
  end if ordered_filters
82
83
  end
@@ -7,12 +7,13 @@
7
7
  sortable: false,
8
8
  cacheAll: true,
9
9
  regional: {
10
+ add: t("admin.misc.add_new"),
10
11
  chooseAll: t("admin.misc.chose_all"),
11
- chosen: t("admin.misc.chosen", name: config.label_plural),
12
12
  clearAll: t("admin.misc.clear_all"),
13
+ down: t("admin.misc.down"),
14
+ remove: t("admin.misc.remove"),
13
15
  search: t("admin.misc.search"),
14
- up: t("admin.misc.up"),
15
- down: t("admin.misc.down")
16
+ up: t("admin.misc.up")
16
17
  }
17
18
  }
18
19
  = form.select field.method_name, field.enum, { selected: field.form_value, object: form.object }, field.html_attributes.reverse_merge({data: { filteringmultiselect: true, options: js_data.to_json }, multiple: true})
@@ -29,12 +29,13 @@
29
29
  removable: !!field.removable,
30
30
  cacheAll: !!field.associated_collection_cache_all,
31
31
  regional: {
32
- chooseAll: t("admin.misc.chose_all"),
33
- chosen: t("admin.misc.chosen", name: config.label_plural),
34
- clearAll: t("admin.misc.clear_all"),
35
- search: t("admin.misc.search"),
36
- up: t("admin.misc.up"),
37
- down: t("admin.misc.down")
32
+ add: t('admin.misc.add_new'),
33
+ chooseAll: t('admin.misc.chose_all'),
34
+ clearAll: t('admin.misc.clear_all'),
35
+ down: t('admin.misc.down'),
36
+ remove: t('admin.misc.remove'),
37
+ search: t('admin.misc.search'),
38
+ up: t('admin.misc.up')
38
39
  }
39
40
  }
40
41
 
@@ -35,7 +35,7 @@
35
35
  - else
36
36
  - ''
37
37
  %li
38
- %a{href: '#', :"data-field-label" => field.label, :"data-field-name" => field.name, :"data-field-options" => field_options.html_safe, :"data-field-type" => field.type, :"data-field-value" => "", :"data-field-datetimepicker-format" => (field.try(:parser) && field.parser.to_momentjs)}= capitalize_first_letter(field.label)
38
+ %a{href: '#', :"data-field-label" => field.label, :"data-field-name" => field.name, :"data-field-operator" => field.default_filter_operator, :"data-field-options" => field_options.html_safe, :"data-field-required" => field.required.to_s, :"data-field-type" => field.type, :"data-field-value" => "", :"data-field-datetimepicker-format" => (field.try(:parser) && field.parser.to_momentjs)}= capitalize_first_letter(field.label)
39
39
 
40
40
  %style
41
41
  - properties.select{ |p| p.column_width.present? }.each do |property|
@@ -36,7 +36,6 @@ en:
36
36
  bulk_menu_title: "Selected items"
37
37
  remove: "Remove"
38
38
  add_new: "Add new"
39
- chosen: "Chosen %{name}"
40
39
  chose_all: "Choose all"
41
40
  clear_all: "Clear all"
42
41
  up: "Up"
@@ -71,11 +71,17 @@ module RailsAdmin
71
71
  delegate :primary_key, :table_name, to: :model, prefix: false
72
72
 
73
73
  def encoding
74
- case ::ActiveRecord::Base.connection_config[:adapter]
74
+ adapter =
75
+ if ::ActiveRecord::Base.respond_to?(:connection_db_config)
76
+ ::ActiveRecord::Base.connection_db_config.configuration_hash[:adapter]
77
+ else
78
+ ::ActiveRecord::Base.connection_config[:adapter]
79
+ end
80
+ case adapter
75
81
  when 'postgresql'
76
82
  ::ActiveRecord::Base.connection.select_one("SELECT ''::text AS str;").values.first.encoding
77
83
  when 'mysql2'
78
- ::ActiveRecord::Base.connection.instance_variable_get(:@connection).encoding
84
+ ::ActiveRecord::Base.connection.raw_connection.encoding
79
85
  when 'oracle_enhanced'
80
86
  ::ActiveRecord::Base.connection.select_one("SELECT dummy FROM DUAL").values.first.encoding
81
87
  else
@@ -20,7 +20,7 @@ module RailsAdmin
20
20
  end
21
21
 
22
22
  def save(options = {validate: true})
23
- object.save(options)
23
+ object.save(**options)
24
24
  end
25
25
 
26
26
  def method_missing(method_name, *args, &block)
@@ -82,9 +82,6 @@ module RailsAdmin
82
82
  attr_accessor :navigation_static_links
83
83
  attr_accessor :navigation_static_label
84
84
 
85
- # yell about fields that are not marked as accessible
86
- attr_accessor :yell_for_non_accessible_fields
87
-
88
85
  # Setup authentication to be run as a before filter
89
86
  # This is run inside the controller instance so you can setup any authentication you need to
90
87
  #
@@ -271,7 +268,6 @@ module RailsAdmin
271
268
  def reset
272
269
  @compact_show_view = true
273
270
  @browser_validations = true
274
- @yell_for_non_accessible_fields = true
275
271
  @authenticate = nil
276
272
  @authorize = nil
277
273
  @audit = nil
@@ -227,6 +227,10 @@ module RailsAdmin
227
227
  bindings[:view].render partial: "rails_admin/main/#{partial}", locals: {field: self, form: bindings[:form]}
228
228
  end
229
229
 
230
+ register_instance_option :default_filter_operator do
231
+ nil
232
+ end
233
+
230
234
  def editable?
231
235
  !(@properties && @properties.read_only?)
232
236
  end
@@ -8,7 +8,11 @@ module RailsAdmin
8
8
  RailsAdmin::Config::Fields::Types.register(self)
9
9
 
10
10
  register_instance_option :thumb_method do
11
- {resize: '100x100>'}
11
+ if ::ActiveStorage::VERSION::MAJOR >= 6
12
+ {resize_to_limit: [100, 100]}
13
+ else
14
+ {resize: '100x100>'}
15
+ end
12
16
  end
13
17
 
14
18
  register_instance_option :delete_method do
@@ -31,6 +31,10 @@ module RailsAdmin
31
31
  resource_url.to_s
32
32
  end
33
33
 
34
+ register_instance_option :link_name do
35
+ value
36
+ end
37
+
34
38
  register_instance_option :pretty_value do
35
39
  if value.presence
36
40
  v = bindings[:view]
@@ -40,7 +44,7 @@ module RailsAdmin
40
44
  image_html = v.image_tag(thumb_url, class: 'img-thumbnail')
41
45
  url != thumb_url ? v.link_to(image_html, url, target: '_blank', rel: 'noopener noreferrer') : image_html
42
46
  else
43
- v.link_to(value, url, target: '_blank', rel: 'noopener noreferrer')
47
+ v.link_to(link_name, url, target: '_blank', rel: 'noopener noreferrer')
44
48
  end
45
49
  end
46
50
  end
@@ -9,7 +9,11 @@ module RailsAdmin
9
9
 
10
10
  class ActiveStorageAttachment < RailsAdmin::Config::Fields::Types::MultipleFileUpload::AbstractAttachment
11
11
  register_instance_option :thumb_method do
12
- {resize: '100x100>'}
12
+ if ::ActiveStorage::VERSION::MAJOR >= 6
13
+ {resize_to_limit: [100, 100]}
14
+ else
15
+ {resize: '100x100>'}
16
+ end
13
17
  end
14
18
 
15
19
  register_instance_option :delete_value do
@@ -38,7 +38,8 @@ module RailsAdmin
38
38
  image_html = v.image_tag(thumb_url, class: 'img-thumbnail')
39
39
  url != thumb_url ? v.link_to(image_html, url, target: '_blank', rel: 'noopener noreferrer') : image_html
40
40
  else
41
- v.link_to(value, url, target: '_blank', rel: 'noopener noreferrer')
41
+ display_value = value.respond_to?(:filename) ? value.filename : value
42
+ v.link_to(display_value, url, target: '_blank', rel: 'noopener noreferrer')
42
43
  end
43
44
  end
44
45
  end
@@ -10,14 +10,16 @@ module RailsAdmin
10
10
  register_instance_option :thumb_method do
11
11
  unless defined? @thumb_method
12
12
  @thumb_method = begin
13
- next nil unless value.is_a?(Hash)
13
+ next nil unless bindings[:object].respond_to?("#{name}_derivatives")
14
14
 
15
- if value.key?(:thumb)
15
+ derivatives = bindings[:object].public_send("#{name}_derivatives")
16
+
17
+ if derivatives.key?(:thumb)
16
18
  :thumb
17
- elsif value.key?(:thumbnail)
19
+ elsif derivatives.key?(:thumbnail)
18
20
  :thumbnail
19
21
  else
20
- value.keys.first
22
+ derivatives.keys.first
21
23
  end
22
24
  end
23
25
  end
@@ -29,21 +31,21 @@ module RailsAdmin
29
31
  end
30
32
 
31
33
  register_instance_option :cache_method do
32
- name
34
+ name if bindings[:object].try("cached_#{name}_data")
33
35
  end
34
36
 
35
37
  register_instance_option :cache_value do
36
- bindings[:object].public_send("cached_#{name}_data") if bindings[:object].respond_to?("cached_#{name}_data")
38
+ bindings[:object].try("cached_#{name}_data")
39
+ end
40
+
41
+ register_instance_option :link_name do
42
+ value.original_filename
37
43
  end
38
44
 
39
45
  def resource_url(thumb = nil)
40
46
  return nil unless value
41
47
 
42
- if value.is_a?(Hash)
43
- value[thumb || value.keys.first].url
44
- else
45
- value.url
46
- end
48
+ thumb && bindings[:object].public_send(:"#{name}", thumb).try(:url) || value.url
47
49
  end
48
50
  end
49
51
  end
@@ -1,8 +1,8 @@
1
1
  module RailsAdmin
2
2
  class Version
3
3
  MAJOR = 2
4
- MINOR = 0
5
- PATCH = 2
4
+ MINOR = 1
5
+ PATCH = 0
6
6
  PRE = nil
7
7
 
8
8
  class << self
@@ -12,18 +12,27 @@ namespace :rails_admin do
12
12
  desc 'CI env for Travis'
13
13
  task :prepare_ci_env do
14
14
  adapter = ENV['CI_DB_ADAPTER'] || 'sqlite3'
15
- database = ENV['CI_DB_DATABASE'] || ('sqlite3' == adapter ? 'db/development.sqlite3' : 'ci_rails_admin')
15
+ database = ('sqlite3' == adapter ? 'db/development.sqlite3' : 'ci_rails_admin')
16
+ username =
17
+ case adapter
18
+ when 'postgresql'
19
+ 'postgres'
20
+ when 'mysql2'
21
+ 'root'
22
+ else
23
+ ''
24
+ end
16
25
 
17
26
  configuration = {
18
27
  'test' => {
19
28
  'adapter' => adapter,
20
29
  'database' => database,
21
- 'username' => ENV['CI_DB_USERNAME'],
22
- 'password' => ENV['CI_DB_PASSWORD'],
23
- 'host' => ENV['CI_DB_HOST'] || 'localhost',
24
- 'encoding' => ENV['CI_DB_ENCODING'] || 'utf8',
25
- 'pool' => (ENV['CI_DB_POOL'] || 5).to_int,
26
- 'timeout' => (ENV['CI_DB_TIMEOUT'] || 5000).to_int,
30
+ 'username' => username,
31
+ 'password' => ('postgresql' == adapter ? 'postgres' : ''),
32
+ 'host' => '127.0.0.1',
33
+ 'encoding' => 'utf8',
34
+ 'pool' => 5,
35
+ 'timeout' => 5000,
27
36
  },
28
37
  }
29
38
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Michaels-Ober
@@ -9,10 +9,10 @@ authors:
9
9
  - Petteri Kaapa
10
10
  - Benoit Benezech
11
11
  - Mitsuhiro Shibuya
12
- autorequire:
12
+ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-03-17 00:00:00.000000000 Z
15
+ date: 2021-02-28 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: builder
@@ -599,7 +599,7 @@ homepage: https://github.com/sferik/rails_admin
599
599
  licenses:
600
600
  - MIT
601
601
  metadata: {}
602
- post_install_message:
602
+ post_install_message:
603
603
  rdoc_options: []
604
604
  require_paths:
605
605
  - lib
@@ -614,8 +614,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
614
614
  - !ruby/object:Gem::Version
615
615
  version: 1.8.11
616
616
  requirements: []
617
- rubygems_version: 3.0.3
618
- signing_key:
617
+ rubygems_version: 3.2.3
618
+ signing_key:
619
619
  specification_version: 4
620
620
  summary: Admin for Rails
621
621
  test_files: []