i18n_rails_helpers 1.4.8 → 1.4.9
Sign up to get free protection for your applications and to get access to all the features.
@@ -70,8 +70,10 @@ module ContextualLinkHelpers
|
|
70
70
|
end
|
71
71
|
model_name = model.to_s.underscore
|
72
72
|
|
73
|
-
|
74
|
-
|
73
|
+
unless resource_or_model.is_a?(String)
|
74
|
+
# No link if CanCan is used and current user isn't authorized to call this action
|
75
|
+
return if respond_to?(:cannot?) and cannot?(action.to_sym, model)
|
76
|
+
end
|
75
77
|
|
76
78
|
# Option generation
|
77
79
|
case action
|
@@ -80,25 +82,29 @@ module ContextualLinkHelpers
|
|
80
82
|
end
|
81
83
|
|
82
84
|
begin
|
83
|
-
|
84
|
-
|
85
|
-
when :index
|
86
|
-
if explicit_resource_or_model
|
87
|
-
path = polymorphic_path(model)
|
88
|
-
else
|
89
|
-
path = url_for(:action => nil)
|
90
|
-
end
|
91
|
-
when :delete, :destroy
|
92
|
-
if explicit_resource_or_model
|
93
|
-
path = polymorphic_path(resource)
|
94
|
-
else
|
95
|
-
path = url_for(:action => :destroy)
|
96
|
-
end
|
85
|
+
if resource_or_model.is_a?(String)
|
86
|
+
path = resource_or_model
|
97
87
|
else
|
98
|
-
|
99
|
-
|
88
|
+
# Path generation
|
89
|
+
case action
|
90
|
+
when :index
|
91
|
+
if explicit_resource_or_model
|
92
|
+
path = polymorphic_path(model)
|
93
|
+
else
|
94
|
+
path = url_for(:action => nil)
|
95
|
+
end
|
96
|
+
when :delete, :destroy
|
97
|
+
if explicit_resource_or_model
|
98
|
+
path = polymorphic_path(resource)
|
99
|
+
else
|
100
|
+
path = url_for(:action => :destroy)
|
101
|
+
end
|
100
102
|
else
|
101
|
-
|
103
|
+
if explicit_resource_or_model
|
104
|
+
path = polymorphic_path(resource_or_model, :action => action)
|
105
|
+
else
|
106
|
+
path = url_for(:action => action)
|
107
|
+
end
|
102
108
|
end
|
103
109
|
end
|
104
110
|
|