thecore_ui_rails_admin 3.5.6 → 3.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84d7325834c15f7c37c0453e37a2119f345d0d8882e8fb854e2250bb79b90d9a
4
- data.tar.gz: 9c9853d13265171cf7ff5fc72e038f80d133bcf577432c63856f9e51e929cc39
3
+ metadata.gz: 82517711bc83866391503197c8c136d37df3bab42a20da302686782ac2d92852
4
+ data.tar.gz: f1ae5901b365288cf2351feb694373d8d642f6098ce08fa4c40eac9e1a571f8e
5
5
  SHA512:
6
- metadata.gz: 592ccf2d863011637bb0b9932f851a5a3b7e7e9c8dbbc7df8a3b90b3130377c071adccab1c6025a243679814143899d2c0fe9aee45f7c444f7c56c5bb1ed8e3b
7
- data.tar.gz: 00ca13b2277dde2d12035be1bb4ae139a9a5399c1e1ddad33a30f1633162174157a1e1ccede86576a1a60d55b642f33683abae2029130266f1faa6f7e5063940
6
+ metadata.gz: '05394e79590df8da4a8f7098724a9032dbd52ef1d15a6167c011b699247147a12b51eff16e618782f1ced29c2014f3413398c5d8bba08c6882cac744302b7dc7'
7
+ data.tar.gz: d5652f60e21c9881367195d3bb8f1e559e838bb0be4a9b4b8060274f76c8df4f36f6c23ab3dfc081420da405c28ae3ed950a6d652ad33c95c2cc80b1b9aa7a90
@@ -1,4 +1,5 @@
1
1
  en:
2
+ active_record_range_error: "ActiveRecord::RangeError: This may be due to a value being out of range. Please consider using specific filters on attributes to narrow down your query."
2
3
  are_you_sure: Are you sure? This operation, if performed on a wide range of data, can lead to the crash of the server.
3
4
  export: Export
4
5
  export_all: Export All
@@ -1,4 +1,5 @@
1
1
  it:
2
+ active_record_range_error: "ActiveRecord::RangeError: Questo potrebbe essere dovuto a un valore fuori intervallo. Si prega di considerare l'uso di filtri specifici sugli attributi per restringere la query."
2
3
  are_you_sure: Sei sicuro? Questa operazione, se eseguita su una grande quantitá di dati, puó bloccare il server.
3
4
  export: Esporta
4
5
  export_all: Esporta Tutti
@@ -1,9 +1,42 @@
1
1
  class RailsAdminAbstractController < ActionController::Base
2
2
  before_action :set_locale
3
-
3
+
4
+ # Example: Catch foreign key violations or DB constraints
5
+ rescue_from ActiveRecord::StatementInvalid, with: :handle_database_error
6
+
7
+ # Example: Catch generic ActiveRecord errors
8
+ rescue_from ActiveRecord::RecordInvalid, with: :handle_record_invalid
9
+
10
+ rescue_from ActiveRecord::RangeError, with: :handle_database_error
11
+
4
12
  private
5
13
 
14
+ def handle_database_error(exception)
15
+ # Check if this request is coming from Rails Admin
16
+ # if request.path.start_with?(RailsAdmin::Engine.routes.find_script_name({}))
17
+ # If it's a ActiveRecord::RangeError also suggest to use the specific filter on an attribute to explain how to fix
18
+ if exception.is_a?(ActiveRecord::RangeError)
19
+ flash[:error] = I18n.t(:active_record_range_error)
20
+ else
21
+ flash[:error] = "Database Error: #{exception.message}"
22
+ end
23
+ redirect_back(fallback_location: rails_admin.dashboard_path)
24
+ # else
25
+ # # Fallback to default behavior for the rest of your app if you prefer
26
+ # raise exception
27
+ # end
28
+ end
29
+
30
+ def handle_record_invalid(exception)
31
+ # if request.path.start_with?(RailsAdmin::Engine.routes.find_script_name({}))
32
+ flash[:error] = "Validation Error: #{exception.record.errors.full_messages.join(", ")}"
33
+ redirect_back(fallback_location: rails_admin.dashboard_path)
34
+ # else
35
+ # raise exception
36
+ # end
37
+ end
38
+
6
39
  def set_locale
7
40
  I18n.locale = current_user.locale if current_user
8
41
  end
9
- end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module ThecoreUiRailsAdmin
2
- VERSION = "3.5.6".freeze
2
+ VERSION = "3.5.7".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_ui_rails_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.6
4
+ version: 3.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni