rails-add_ons 0.3.0 → 0.3.2
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 +4 -4
- data/app/assets/stylesheets/rails/add_ons/application/table_monospaced.scss +3 -2
- data/app/concerns/api_controller_concerns/exception_handling.rb +17 -11
- data/app/controllers/api/resources_controller/base.rb +20 -0
- data/app/controllers/service_controller/base.rb +10 -1
- data/app/views/resources_controller/base/_show_actions.haml +9 -4
- data/app/views/service_controller/base/create.haml +1 -1
- data/config/locales/de.yml +1 -0
- data/config/locales/en.yml +1 -0
- data/lib/rails/add_ons/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8a915102878fc7b3b90f8fa1eaee71e4adcd496
|
4
|
+
data.tar.gz: a2c2167c5e4f76d9ff265a640d8b4c164e06bd10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcd7f4201424418fceac6cf114559bef248ad628275ff7985b15a54875e69df45f2484c1a6ad763f02bff7ae7c68df4da2c6dc25e4441a327bd3bb5b715a12c4
|
7
|
+
data.tar.gz: a18661c6099af2c0ca8e4c66dcd1b4a98b3dce15aade3d6a703f07af5425d2e57ff6c85bb6938a82ff36ccd232462511faba2962385fa648d97e8a12d68146ef
|
@@ -4,19 +4,25 @@ module ApiControllerConcerns
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
rescue_from Exception do |exception|
|
7
|
-
|
8
|
-
|
7
|
+
handle_exception(exception)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
9
12
|
|
10
|
-
|
11
|
-
|
13
|
+
def handle_exception(exception)
|
14
|
+
if Rails.env.development? || Rails.env.test?
|
15
|
+
error = { message: exception.message }
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
error[:application_trace] = Rails.backtrace_cleaner.clean(exception.backtrace)
|
18
|
+
error[:full_trace] = exception.backtrace
|
19
|
+
|
20
|
+
respond_to do |format|
|
21
|
+
format.json { render json: error, status: 500 }
|
22
|
+
end
|
23
|
+
else
|
24
|
+
respond_to do |format|
|
25
|
+
format.json { render json: { error: 'Internal server error.' }, status: 500 }
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -314,6 +314,26 @@ module Api
|
|
314
314
|
include FirstAction
|
315
315
|
include LastAction
|
316
316
|
include ApiControllerConcerns::ExceptionHandling
|
317
|
+
|
318
|
+
if ActionController.const_defined?('Parameters')
|
319
|
+
class PatchedParameters < ActionController::Parameters
|
320
|
+
def require key
|
321
|
+
begin
|
322
|
+
super key
|
323
|
+
rescue ActionController::ParameterMissing => e
|
324
|
+
if self[key].nil? || self[key].empty?
|
325
|
+
return PatchedParameters.new
|
326
|
+
else
|
327
|
+
raise e
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
def params
|
334
|
+
@_params ||= PatchedParameters.new(request.parameters)
|
335
|
+
end
|
336
|
+
end
|
317
337
|
end
|
318
338
|
end
|
319
339
|
end
|
@@ -32,6 +32,7 @@ module ServiceController
|
|
32
32
|
def perform
|
33
33
|
@result = @resource.perform
|
34
34
|
if @result.success?
|
35
|
+
flash.now[:success] = t('flash.actions.perform.notice', resource_name: @resource.class.model_name.human)
|
35
36
|
render :create
|
36
37
|
else
|
37
38
|
render :new
|
@@ -43,7 +44,15 @@ module ServiceController
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def initialize_service_for_create
|
46
|
-
@resource = service_class.new(
|
47
|
+
@resource = service_class.new(hashified_params)
|
48
|
+
end
|
49
|
+
|
50
|
+
def hashified_params
|
51
|
+
if permitted_params.respond_to?(:to_h)
|
52
|
+
permitted_params.to_h
|
53
|
+
else
|
54
|
+
permitted_params
|
55
|
+
end
|
47
56
|
end
|
48
57
|
|
49
58
|
def permitted_params
|
@@ -1,6 +1,11 @@
|
|
1
|
-
=
|
2
|
-
=
|
3
|
-
|
1
|
+
= bootstrap_button_group do
|
2
|
+
= bootstrap_button(to: edit_resource_path(resource), context: :secondary) do
|
3
|
+
= fa_icon(:pencil)
|
4
|
+
= t('.edit')
|
5
|
+
|
6
|
+
= bootstrap_button(to: resource_path(resource), context: :danger, method: :delete, data: { confirm: 'Are you sure?' }) do
|
7
|
+
= fa_icon :trash
|
8
|
+
= t('.delete')
|
4
9
|
|
5
10
|
= bootstrap_button(to: collection_path, context: :link) do
|
6
|
-
= t('.back')
|
11
|
+
= t('.back')
|
data/config/locales/de.yml
CHANGED
data/config/locales/en.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-add_ons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|