go_to_param 0.0.3 → 0.0.4
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/README.md +5 -5
- data/lib/go_to_param/version.rb +1 -1
- data/lib/go_to_param.rb +3 -3
- data/spec/go_to_param_spec.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e85034c2269a1d8427dedad5de680834830606d5
|
4
|
+
data.tar.gz: 6733a2d52caee86fcbbf91f1be323540878d7f03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f7b906a453c63d6b94b6b92c5a8727d03188979b2778c26b3f40544ef4cae4464cc67252984a7b681587f76bcf2a5c3072d41a51c93371778b68d9e034bec71
|
7
|
+
data.tar.gz: 5cfea1660f505122b2ffa47e39f3d850e2370630ae9ef015ebc98d4d99770db09a764bc2121bd9a3668df0ece67b329d19d97936e4ef33b62a43b96cc34b0bfa
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
|
15
15
|
Now your controllers and views get some methods.
|
16
16
|
|
17
|
-
###
|
17
|
+
### build_go_to_hash
|
18
18
|
|
19
19
|
Put the current/requested path in a `?go_to=` parameter.
|
20
20
|
|
@@ -28,7 +28,7 @@ class ApplicationController < ActionController::Base
|
|
28
28
|
|
29
29
|
def ensure_authenticated
|
30
30
|
unless authenticated?
|
31
|
-
redirect_to login_path(
|
31
|
+
redirect_to login_path(build_go_to_hash)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -49,18 +49,18 @@ Pass the `go_to` parameter along with a form.
|
|
49
49
|
</form>
|
50
50
|
```
|
51
51
|
|
52
|
-
###
|
52
|
+
### go_to_hash
|
53
53
|
|
54
54
|
Pass the `go_to` parameter along with a link.
|
55
55
|
|
56
56
|
``` erb
|
57
|
-
<%= link_to("Reset password", password_reset_path(
|
57
|
+
<%= link_to("Reset password", password_reset_path(go_to_hash)) %>
|
58
58
|
```
|
59
59
|
|
60
60
|
You can pass in additional parameters for the given path:
|
61
61
|
|
62
62
|
``` erb
|
63
|
-
<%= link_to("Reset password", password_reset_path(
|
63
|
+
<%= link_to("Reset password", password_reset_path(go_to_hash(email: @email))) %>
|
64
64
|
```
|
65
65
|
|
66
66
|
### go_to_path
|
data/lib/go_to_param/version.rb
CHANGED
data/lib/go_to_param.rb
CHANGED
@@ -2,18 +2,18 @@ require "go_to_param/version"
|
|
2
2
|
|
3
3
|
module GoToParam
|
4
4
|
def self.included(klass)
|
5
|
-
klass.helper_method :hidden_go_to_tag, :
|
5
|
+
klass.helper_method :hidden_go_to_tag, :go_to_hash
|
6
6
|
end
|
7
7
|
|
8
8
|
def hidden_go_to_tag
|
9
9
|
view_context.hidden_field_tag :go_to, go_to_path
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
12
|
+
def go_to_hash(other_params = {})
|
13
13
|
{ go_to: go_to_path }.merge(other_params)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def build_go_to_hash
|
17
17
|
if request.get?
|
18
18
|
{ go_to: request.fullpath }
|
19
19
|
else
|
data/spec/go_to_param_spec.rb
CHANGED
@@ -33,33 +33,33 @@ describe GoToParam do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe "#
|
36
|
+
describe "#go_to_hash" do
|
37
37
|
it "makes it a helper method" do
|
38
|
-
FakeController.helper_methods.should include :
|
38
|
+
FakeController.helper_methods.should include :go_to_hash
|
39
39
|
end
|
40
40
|
|
41
41
|
it "includes the go_to parameter" do
|
42
42
|
controller.params = { go_to: "/example", id: "1" }
|
43
43
|
|
44
|
-
controller.
|
44
|
+
controller.go_to_hash.should == { go_to: "/example" }
|
45
45
|
end
|
46
46
|
|
47
47
|
it "accepts additional parameters" do
|
48
48
|
controller.params = { go_to: "/example", id: "1" }
|
49
49
|
|
50
|
-
controller.
|
50
|
+
controller.go_to_hash(a: "b").should == { go_to: "/example", a: "b" }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe "#
|
54
|
+
describe "#build_go_to_hash" do
|
55
55
|
it "gets the request path as the go_to parameter" do
|
56
56
|
controller.request = double(get?: true, fullpath: "/example")
|
57
|
-
controller.
|
57
|
+
controller.build_go_to_hash.should == { go_to: "/example" }
|
58
58
|
end
|
59
59
|
|
60
60
|
it "returns an empty hash for a non-GET request" do
|
61
61
|
controller.request = double(get?: false, fullpath: "/example")
|
62
|
-
controller.
|
62
|
+
controller.build_go_to_hash.should == {}
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|