effective_resources 1.8.7 → 1.8.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79cab109b01cb0133d18f3530e8ed872c183c8e637c8279da87bbd068ddbee21
4
- data.tar.gz: 20e8cb596ab2181fde595dc430c2e57fa1396b7d91490827d496e20438f59575
3
+ metadata.gz: 7247ed4940067b7becde627b02de2ccc38e8fa425b0a43f1080e60b40b4c57dc
4
+ data.tar.gz: 38939264d4747f0d2f83a306c9d0fc4e474e6f6303dd612d47e40390a0cf0e8e
5
5
  SHA512:
6
- metadata.gz: b4ed96cdaf9a6fb68f51b3328fde6b38151f595f09e94fbc8943f034d0de2a9ae48a959f07c050fc77a8bfcaa8d1b6be0f671e7d23e762de51771cc58a6c8779
7
- data.tar.gz: feaa6d1027ba1b6315a922b400feab502bc1f96e545092e4d9f9284f9cd935e80e918dd2b2e93fb5b0f2391b59978aaa908c1663ec112d10c9bd3cde819c830b
6
+ metadata.gz: a42dba0d42144cae133a766cebe9192d0257e3a0610a4535c163311f193923c56b5b21c15a4643d842557945d66d5a68faac4c0b1934ec406ce99ef8e991d5ad
7
+ data.tar.gz: fd8659905534432f07004a55d072dab21ab2c87e9f374c4b54fef68d8bec93450f68637200d598c430575b72969e3d156a419bd349ca54eb6460f0412acda4cc
@@ -2,7 +2,7 @@ module Effective
2
2
  module CrudController
3
3
  module Paths
4
4
 
5
- def resource_redirect_path(action = nil)
5
+ def resource_redirect_path(resource, action)
6
6
  submit = commit_action(action)
7
7
  redirect = submit[:redirect].respond_to?(:call) ? instance_exec(&submit[:redirect]) : submit[:redirect]
8
8
 
@@ -39,13 +39,29 @@ module Effective
39
39
  # Otherwise consider the action
40
40
  commit_default_redirect = case action
41
41
  when :create
42
- [resource_show_path, resource_edit_path, resource_index_path]
42
+ [
43
+ (resource_show_path if EffectiveResources.authorized?(self, :show, resource)),
44
+ (resource_edit_path if EffectiveResources.authorized?(self, :edit, resource)),
45
+ (resource_index_path if EffectiveResources.authorized?(self, :index, resource.class))
46
+ ]
43
47
  when :update
44
- [resource_edit_path, resource_show_path, resource_index_path]
48
+ [
49
+ (resource_edit_path if EffectiveResources.authorized?(self, :edit, resource)),
50
+ (resource_show_path if EffectiveResources.authorized?(self, :show, resource)),
51
+ (resource_index_path if EffectiveResources.authorized?(self, :index, resource.class))
52
+ ]
45
53
  when :destroy
46
- [referer_redirect_path, resource_index_path]
54
+ [
55
+ referer_redirect_path,
56
+ (resource_index_path if EffectiveResources.authorized?(self, :index, resource.class))
57
+ ]
47
58
  else
48
- [referer_redirect_path, resource_edit_path, resource_show_path, resource_index_path]
59
+ [
60
+ referer_redirect_path,
61
+ (resource_edit_path if EffectiveResources.authorized?(self, :edit, resource)),
62
+ (resource_show_path if EffectiveResources.authorized?(self, :show, resource)),
63
+ (resource_index_path if EffectiveResources.authorized?(self, :index, resource.class))
64
+ ]
49
65
  end.compact.first
50
66
 
51
67
  return commit_default_redirect if commit_default_redirect.present?
@@ -10,12 +10,12 @@ module Effective
10
10
  respond_to do |format|
11
11
  format.html do
12
12
  flash[:success] ||= resource_flash(:success, resource, action)
13
- redirect_to(resource_redirect_path(action))
13
+ redirect_to(resource_redirect_path(resource, action))
14
14
  end
15
15
 
16
16
  format.js do
17
17
  flash[:success] ||= resource_flash(:success, resource, action)
18
- redirect_to(resource_redirect_path(action))
18
+ redirect_to(resource_redirect_path(resource, action))
19
19
  end
20
20
  end
21
21
  elsif template_present?(action)
@@ -35,7 +35,7 @@ module Effective
35
35
  respond_to do |format|
36
36
  format.html do
37
37
  flash[:success] ||= resource_flash(:success, resource, action)
38
- redirect_to(resource_redirect_path(action))
38
+ redirect_to(resource_redirect_path(resource, action))
39
39
  end
40
40
 
41
41
  format.js do
@@ -61,7 +61,7 @@ module Effective
61
61
  when :destroy
62
62
  format.html do
63
63
  redirect_flash
64
- redirect_to(resource_redirect_path(action))
64
+ redirect_to(resource_redirect_path(resource, action))
65
65
  end
66
66
  else
67
67
  if template_present?(action)
@@ -73,7 +73,7 @@ module Effective
73
73
  else
74
74
  format.html do
75
75
  redirect_flash
76
- redirect_to(resource_redirect_path(action))
76
+ redirect_to(resource_redirect_path(resource, action))
77
77
  end
78
78
  end
79
79
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.8.7'.freeze
2
+ VERSION = '1.8.8'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.7
4
+ version: 1.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect