rails_admin 1.4.1 → 1.4.2

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
  SHA1:
3
- metadata.gz: a17f479765c10aa74200405742f1387eea769ee8
4
- data.tar.gz: b4efbfa19a87163d641b50aa4771b5eddddaa336
3
+ metadata.gz: 304c4e0f0cb8e46bab128045cd480163e9b86e6e
4
+ data.tar.gz: e3a2a9e2c86f2227c0b8b9b3cdf955b4695154dd
5
5
  SHA512:
6
- metadata.gz: 20351d651d98ba0ac84171a0812b19394f5e2853598ae92a23069e979cea27b99161acfc9792621eb4da947539dc3d687371ad27832086f41740e77b6fe020c4
7
- data.tar.gz: e00d12b32c662017293acff322855a9c6f5a479c151990664df3eac5568c6367c84fa4e908f6c5b3ebb6204b6bf78199ac22f304a01ca4bc4e291605e5df3e27
6
+ metadata.gz: 1d489cc488adace10d7645b530f303e81cf96f981fddda20a01b9ff93e3b36678b23fe1ddd277d99a606c3ddec57c61851ebbace6d2e1515d7f36db97b49153a
7
+ data.tar.gz: 7bfe657ca2eb9c41646736d33985adcc02fb1184689e0f69320f4a9fc838c15fb139f43872570be8752021a9387a077bd87d88acbd39458c9df027250a7cdd77
@@ -43,7 +43,8 @@ module RailsAdmin
43
43
  Dir[File.join(File.dirname(__FILE__), '../tasks/*.rake')].each { |f| load f }
44
44
  end
45
45
 
46
- initializer 'RailsAdmin check for required middlewares', after: :build_middleware_stack do |app|
46
+ # Check for required middlewares, can be missing in Rails API mode
47
+ config.after_initialize do |app|
47
48
  has_session_store = app.config.middleware.to_a.any? { |m| m.klass.try(:<=, ActionDispatch::Session::AbstractStore) } || ::Rails.version < '5.0'
48
49
  loaded = app.config.middleware.to_a.map(&:name)
49
50
  required = %w(ActionDispatch::Cookies ActionDispatch::Flash Rack::MethodOverride)
@@ -37,6 +37,16 @@ module RailsAdmin
37
37
  created_at: :created_at,
38
38
  message: :event,
39
39
  }.freeze
40
+ E_VERSION_MODEL_NOT_SET = <<-EOS.strip_heredoc.freeze
41
+ Please set up PaperTrail's version model explicitly.
42
+
43
+ config.audit_with :paper_trail, 'User', 'PaperTrail::Version'
44
+
45
+ If you have configured a model to use a custom version class
46
+ (https://github.com/paper-trail-gem/paper_trail#6a-custom-version-classes)
47
+ that configuration will take precedence over what you specify in
48
+ `audit_with`.
49
+ EOS
40
50
 
41
51
  def self.setup
42
52
  raise('PaperTrail not found') unless defined?(::PaperTrail)
@@ -59,7 +69,7 @@ module RailsAdmin
59
69
  begin
60
70
  @version_class = version_class.to_s.constantize
61
71
  rescue NameError
62
- raise "Please set up Papertrail's version model explicitly. Ex: config.audit_with :paper_trail, 'User', 'PaperTrail::Version'"
72
+ raise E_VERSION_MODEL_NOT_SET
63
73
  end
64
74
  end
65
75
 
@@ -91,6 +101,7 @@ module RailsAdmin
91
101
 
92
102
  protected
93
103
 
104
+ # - model - a RailsAdmin::AbstractModel
94
105
  def listing_for_model_or_object(model, object, query, sort, sort_reverse, all, page, per_page)
95
106
  if sort.present?
96
107
  sort = COLUMN_MAPPING[sort.to_sym]
@@ -99,11 +110,10 @@ module RailsAdmin
99
110
  sort_reverse = 'true'
100
111
  end
101
112
 
102
- model_name = model.model.name
103
-
113
+ ar_model = model.model
104
114
  current_page = page.presence || '1'
105
115
 
106
- versions = version_class_for(model_name).where item_type: model_name
116
+ versions = version_class_for(ar_model).where item_type: ar_model.name
107
117
  versions = versions.where item_id: object.id if object
108
118
  versions = versions.where('event LIKE ?', "%#{query}%") if query.present?
109
119
  versions = versions.order(sort_reverse == 'true' ? "#{sort} DESC" : sort)
@@ -116,12 +126,14 @@ module RailsAdmin
116
126
  paginated_proxies
117
127
  end
118
128
 
119
- def version_class_for(model_name)
120
- klass = model_name.constantize.
121
- try(:version_class_name).
122
- try(:constantize)
123
-
124
- klass || @version_class
129
+ # PT can be configured to use [custom version
130
+ # classes](https://github.com/paper-trail-gem/paper_trail#6a-custom-version-classes)
131
+ #
132
+ # ```ruby
133
+ # has_paper_trail class_name: 'MyVersion'
134
+ # ```
135
+ def version_class_for(model)
136
+ model.paper_trail_options[:class_name].try(:constantize) || @version_class
125
137
  end
126
138
  end
127
139
  end
@@ -2,7 +2,7 @@ module RailsAdmin
2
2
  class Version
3
3
  MAJOR = 1
4
4
  MINOR = 4
5
- PATCH = 1
5
+ PATCH = 2
6
6
  PRE = nil
7
7
 
8
8
  class << self
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: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Michaels-Ober
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2018-08-19 00:00:00.000000000 Z
15
+ date: 2018-09-23 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: builder