i18n_rails_helpers 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -59,10 +59,14 @@ module ContextualLinkHelpers
|
|
59
59
|
# Use controller name to guess resource or model if not specified
|
60
60
|
case action
|
61
61
|
when :new, :index
|
62
|
-
|
62
|
+
default_model = controller_name.singularize.camelize.constantize
|
63
|
+
model = resource_or_model || default_model
|
64
|
+
explicit_resource_or_model = default_model != model
|
63
65
|
when :show, :edit, :delete
|
64
|
-
|
66
|
+
default_resource = instance_variable_get("@#{controller_name.singularize}")
|
67
|
+
resource = resource_or_model || default_resource
|
65
68
|
model = resource.class
|
69
|
+
explicit_resource_or_model = default_resource != resource
|
66
70
|
end
|
67
71
|
model_name = model.to_s.underscore
|
68
72
|
|
@@ -78,19 +82,19 @@ module ContextualLinkHelpers
|
|
78
82
|
# Path generation
|
79
83
|
case action
|
80
84
|
when :index
|
81
|
-
if
|
85
|
+
if explicit_resource_or_model
|
82
86
|
path = polymorphic_path(model)
|
83
87
|
else
|
84
88
|
path = url_for(:action => nil)
|
85
89
|
end
|
86
|
-
when :
|
87
|
-
if
|
90
|
+
when :delete, :destroy
|
91
|
+
if explicit_resource_or_model
|
88
92
|
path = polymorphic_path(resource)
|
89
93
|
else
|
90
|
-
|
94
|
+
path = url_for(:action => :destroy)
|
91
95
|
end
|
92
96
|
else
|
93
|
-
if
|
97
|
+
if explicit_resource_or_model
|
94
98
|
path = polymorphic_path(resource_or_model, :action => action)
|
95
99
|
else
|
96
100
|
path = url_for(:action => action)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_rails_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Rails i18n view helpers for things like crud actions, models and and
|
15
15
|
attributes.
|