go_to_param 0.0.9 → 0.0.10

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
  SHA1:
3
- metadata.gz: 575e842ed9760fb96ae10b48648e03a851f7d201
4
- data.tar.gz: 8c3ce348dc9739151ba27c7a14f5656d40cdcad1
3
+ metadata.gz: fea100cfef7c5232e51c706f26493d87d58d00d7
4
+ data.tar.gz: 1151e3917f4c57433a2c2aa9bf5506ab217a1b0c
5
5
  SHA512:
6
- metadata.gz: 4b93398509e61b556f3f12afa630df7a0f7af1bc095d8495dbd9084e41186eb6b5385336d7f068ab01304315020b1598b03dbee8bd63bae073842d956c5384c7
7
- data.tar.gz: 2fd2e88f189dbba5d53410aadc86ca7d84d0801d536a9396db5434c6f7b15dee849fe8eec84e7de60815817041557139965a102aa4167095b2fd959077a23623
6
+ metadata.gz: 19ea749058f98d09dd82ff29d3e530096176b2e618b2f4fe03928bd23257af0f65e1f6057b4f6317fe14892564e20453aaf62cc7d70c91940648b60753eea6f7
7
+ data.tar.gz: c00954fd5782fcc27411ac6b3271404c986afefc8a19f88b96c7b6bb2f996dcc85f421f898721c8b83fca32758392c52bdcb00d0d114fcb91c7cb4f23f603944
data/README.md CHANGED
@@ -10,15 +10,17 @@ Include in some suitable base controller:
10
10
 
11
11
  ``` ruby
12
12
  class ApplicationController < ActionController::Base
13
- include GoToParameter
13
+ include GoToParam
14
14
  end
15
15
  ```
16
16
 
17
17
  Now your controllers and views get some methods.
18
18
 
19
- ### build_go_to_hash
19
+ ### go_to_here_params
20
+
21
+ Put the current/requested path in a `{ go_to: "/the_path" }` parameter hash.
20
22
 
21
- Put the current/requested path in a `?go_to=` parameter.
23
+ Perhaps from a controller:
22
24
 
23
25
  ``` ruby
24
26
  class ApplicationController < ActionController::Base
@@ -30,13 +32,20 @@ class ApplicationController < ActionController::Base
30
32
 
31
33
  def ensure_authenticated
32
34
  unless authenticated?
33
- redirect_to login_path(build_go_to_hash)
35
+ redirect_to login_path(go_to_here_params)
34
36
  end
35
37
  end
36
38
  end
37
39
  ```
38
40
 
39
- Only picks up the requested path if it's a GET, since we can't redirect back to a non-GET later.
41
+ Or a view:
42
+
43
+ ``` erb
44
+ <h1>Show item</h1>
45
+ <%= link_to("Edit item", edit_item_path(@item, go_to_here_params))
46
+ ```
47
+
48
+ This only picks up the requested path if it's a GET, since we can't redirect back to a non-GET later. Otherwise an empty hash is returned.
40
49
 
41
50
  ### hidden_go_to_tag
42
51
 
@@ -51,18 +60,18 @@ Pass the `go_to` parameter along with a form.
51
60
  </form>
52
61
  ```
53
62
 
54
- ### go_to_hash
63
+ ### go_to_params
55
64
 
56
65
  Pass the `go_to` parameter along with a link.
57
66
 
58
67
  ``` erb
59
- <%= link_to("Reset password", password_reset_path(go_to_hash)) %>
68
+ <%= link_to("Reset password", password_reset_path(go_to_params)) %>
60
69
  ```
61
70
 
62
71
  You can pass in additional parameters for the given path:
63
72
 
64
73
  ``` erb
65
- <%= link_to("Reset password", password_reset_path(go_to_hash(email: @email))) %>
74
+ <%= link_to("Reset password", password_reset_path(go_to_params(email: @email))) %>
66
75
  ```
67
76
 
68
77
  ### go_to_path
@@ -1,3 +1,3 @@
1
1
  module GoToParam
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/lib/go_to_param.rb CHANGED
@@ -3,7 +3,7 @@ require "go_to_param/version"
3
3
  module GoToParam
4
4
  def self.included(klass)
5
5
  klass.helper_method :hidden_go_to_tag,
6
- :go_to_hash, :build_go_to_hash,
6
+ :go_to_params, :go_to_here_params,
7
7
  :go_to_path, :go_to_path_or
8
8
  end
9
9
 
@@ -11,11 +11,11 @@ module GoToParam
11
11
  view_context.hidden_field_tag :go_to, go_to_path
12
12
  end
13
13
 
14
- def go_to_hash(other_params = {})
14
+ def go_to_params(other_params = {})
15
15
  { go_to: go_to_path }.merge(other_params)
16
16
  end
17
17
 
18
- def build_go_to_hash
18
+ def go_to_here_params
19
19
  if request.get?
20
20
  { go_to: request.fullpath }
21
21
  else
@@ -33,37 +33,37 @@ describe GoToParam do
33
33
  end
34
34
  end
35
35
 
36
- describe "#go_to_hash" do
36
+ describe "#go_to_params" do
37
37
  it "becomes a helper method" do
38
- FakeController.helper_methods.should include :go_to_hash
38
+ FakeController.helper_methods.should include :go_to_params
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.go_to_hash.should == { go_to: "/example" }
44
+ controller.go_to_params.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.go_to_hash(a: "b").should == { go_to: "/example", a: "b" }
50
+ controller.go_to_params(a: "b").should == { go_to: "/example", a: "b" }
51
51
  end
52
52
  end
53
53
 
54
- describe "#build_go_to_hash" do
54
+ describe "#go_to_here_params" do
55
55
  it "becomes a helper method" do
56
- FakeController.helper_methods.should include :build_go_to_hash
56
+ FakeController.helper_methods.should include :go_to_here_params
57
57
  end
58
58
 
59
59
  it "gets the request path as the go_to parameter" do
60
60
  controller.request = double(get?: true, fullpath: "/example")
61
- controller.build_go_to_hash.should == { go_to: "/example" }
61
+ controller.go_to_here_params.should == { go_to: "/example" }
62
62
  end
63
63
 
64
64
  it "returns an empty hash for a non-GET request" do
65
65
  controller.request = double(get?: false, fullpath: "/example")
66
- controller.build_go_to_hash.should == {}
66
+ controller.go_to_here_params.should == {}
67
67
  end
68
68
  end
69
69
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_to_param
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik N