ransack_memory 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/app/controllers/concerns/ransack_memory/concern.rb +7 -4
- data/lib/ransack_memory/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7b6a8a9db701878b3ea62f2af3b217c4cd2311c
|
4
|
+
data.tar.gz: 123cf3cf2b9a5bdb7667836823779f8076a34398
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1ff6fe707d3acc50e98da6112f335c8bee0eb6b8b0e8e04f8e70fdd3a636224a03b5777c16deeb2f82e1d1cb4cb385b02c9647c856ca5331f17da02f6158dd3
|
7
|
+
data.tar.gz: 4f345e31551be326d944e5ec8c7dab441ce8ff5bf0f670c126cb421eec787eda87f84f470748312d26db2d5428336847bdf8a1f40faf2e26c2f58f3f435c81dc
|
data/README.md
CHANGED
@@ -43,6 +43,18 @@ RansackMemory::Core.config = {
|
|
43
43
|
|
44
44
|
Or you can generate this config file by running ```rails generate ransack_memory``` in console.
|
45
45
|
|
46
|
+
## Load saved filters from another controller action
|
47
|
+
|
48
|
+
In some cases, you want to load saved filters from another controller action. If so, you just create in the same controller this method:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
def set_session_key_identifier
|
52
|
+
'projects_index_html' if action_name == 'my_another_action'
|
53
|
+
end
|
54
|
+
```
|
55
|
+
this means that Ransack Memory load all filters that have been saved in action projects/index.html and load them into projects/my_another_action. This method must be public, not in private section!
|
56
|
+
Standard session key building is: ```"#{controller_name}_#{action_name}_#{request.format}"``` so you can load saved filters in any controller action like that.
|
57
|
+
|
46
58
|
## Kaminari issue
|
47
59
|
|
48
60
|
When you have an issue with Kaminari gem, that you can't go back to the first page, update your kaminari view in `app/views/kaminari/_first_page.html.erb`:
|
@@ -3,12 +3,15 @@ module RansackMemory
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
def save_and_load_filters
|
6
|
+
user_set_key_identifier = respond_to?(:set_session_key_identifier) ? send(:set_session_key_identifier) : nil
|
7
|
+
|
6
8
|
session_key_identifier = ::RansackMemory::Core.config[:session_key_format]
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
.gsub('%controller_name%', controller_name)
|
10
|
+
.gsub('%action_name%', action_name)
|
11
|
+
.gsub('%request_format%', request.format.symbol.to_s)
|
10
12
|
|
11
|
-
session_key_base = "ranmemory_#{session_key_identifier}"
|
13
|
+
session_key_base = user_set_key_identifier.presence || "ranmemory_#{session_key_identifier}"
|
14
|
+
session_key_base = "ranmemory_#{session_key_base}" unless session_key_base.starts_with?('ranmemory')
|
12
15
|
|
13
16
|
# permit search params
|
14
17
|
params[::RansackMemory::Core.config[:param]].permit! if params[::RansackMemory::Core.config[:param]].present? && params[::RansackMemory::Core.config[:param]].respond_to?(:permit)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ransack_memory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Lapiš
|
@@ -36,17 +36,17 @@ require_paths:
|
|
36
36
|
- lib
|
37
37
|
required_ruby_version: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 1.9.3
|
42
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
48
|
rubyforge_project:
|
49
|
-
rubygems_version: 2.
|
49
|
+
rubygems_version: 2.4.8
|
50
50
|
signing_key:
|
51
51
|
specification_version: 3
|
52
52
|
summary: Automatically save and load ransack's filtered params into session
|