redirect_on_back 0.0.4 → 0.0.5
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 +8 -8
- data/README.md +10 -0
- data/lib/redirect_on_back/railtie.rb +10 -1
- data/lib/redirect_on_back/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWU0ZDJkZTk4MmYzY2Q5ZTczMmZiNGQwNTYzNDRjYjY4ZmQ3YmE0Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjJjZWRiYmZjMTYzZDA1MjY3MWQzNGMyMjI0NWRmZGQ3MGE2Mjk2Ng==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzE0NmIyOWY3MjJjNzJmYTFjYzkwYTU4NzNlYmZlNjQ2NzE3NWFlM2NkNGU5
|
10
|
+
OTA0ZjFmZTMyNGEwZDY4ZTk3MzZiZTI1MDU0MDdhODczN2M0MzJjZGNkNDAx
|
11
|
+
NGViYTlhNzMyYzEwNmE0YjcwZTMzMmFiYjk3NDg4ODgxMzQ4ZmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTdhYTZlOGY1YzNjZjRlYzU5NjYyNTBiOWQ3MzY5NDIxZWM1ZGU0ZWYzMTI1
|
14
|
+
MWRkOGZlY2JhZGMxN2ZlYTg5NTc1NzliMTFiMTJkMmIxYTRlMzIwMzdhZmU4
|
15
|
+
Y2I4MThhMTkyMmUzNTAwMWE1YWVmMjg0NzNkYzVjNmVhNDNhYjE=
|
data/README.md
CHANGED
@@ -42,6 +42,16 @@ In your controller actions:
|
|
42
42
|
end
|
43
43
|
```
|
44
44
|
|
45
|
+
## How to Disable
|
46
|
+
|
47
|
+
`redirect_on_back` uses a hidden form field, which it automatically adds to forms.
|
48
|
+
However, it doesn't add the field to forms that point to different domains.
|
49
|
+
If you need to disable it in another forms, simply add `disable_redirect_on_back: true` to the `data` hash of that form:
|
50
|
+
|
51
|
+
```erb
|
52
|
+
form_tag :user, data: {disable_redirect_on_back: true}
|
53
|
+
```
|
54
|
+
|
45
55
|
## Contributing
|
46
56
|
|
47
57
|
1. Fork it
|
@@ -8,11 +8,20 @@ module RedirectOnBack
|
|
8
8
|
|
9
9
|
def extra_tags_for_form(html_options)
|
10
10
|
orig_tags = orig_extra_tags_for_form(html_options)
|
11
|
-
|
11
|
+
if !disable_redirect_on_back(html_options) && is_internal_action?(html_options[:action] || '/')
|
12
12
|
orig_tags << "<input name='_usec' type='hidden' value='#{Time.now.usec}' />".html_safe
|
13
13
|
end
|
14
14
|
orig_tags
|
15
15
|
end
|
16
|
+
|
17
|
+
def disable_redirect_on_back(html_options)
|
18
|
+
html_options.try(:[], :data).try(:delete, :disable_redirect_on_back)
|
19
|
+
end
|
20
|
+
|
21
|
+
def is_internal_action?(action)
|
22
|
+
(action =~ /^\//) != nil # form action starts with '/'
|
23
|
+
end
|
24
|
+
|
16
25
|
end
|
17
26
|
end
|
18
27
|
end
|