rao-resources_controller 0.0.20.pre → 0.0.21.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/concerns/rao/resources_controller/kaminari_concern.rb +9 -1
- data/app/concerns/rao/resources_controller/will_paginate_concern.rb +9 -13
- data/lib/generators/rao/resources_controller/templates/initializer.rb +8 -0
- data/lib/rao/resources_controller/configuration.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fff12e71b5abd4c04de6759e3ca9d0ce5784ae2388b57729ffa1a4c356f075c
|
4
|
+
data.tar.gz: d0a06e05b176b0f90ad9ed86fdf0532c7d48ad1e40e4622659bf3ac93b66ecac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16995d2c6e3fda2857fbd91952121bde6cf9a1a41da5216df92935a3e93a8baebdd69b335f47d7358b1fcf6d04f66046263e992bb0fb63209706a680df41eb9f
|
7
|
+
data.tar.gz: 5d6a6dfc118a14b62e040d16d3767d72480fe01cda552cc68964399af26a915a186e085622745e17fbd4200ed4157fc34914ba5a6b8c333cda8178cfe9e84814
|
@@ -13,7 +13,15 @@ module Rao
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def load_collection
|
16
|
-
@collection = load_collection_scope.page(params[:page])
|
16
|
+
@collection = load_collection_scope.page(params[:page]).per(per_page)
|
17
|
+
end
|
18
|
+
|
19
|
+
def per_page
|
20
|
+
if [nil, 'all'].include?(params[:per_page])
|
21
|
+
nil
|
22
|
+
else
|
23
|
+
Rao::ResourcesController::Configuration.pagination_per_page_default
|
24
|
+
end
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -1,16 +1,4 @@
|
|
1
1
|
module Rao
|
2
|
-
# Setting the pagination size in the controller:
|
3
|
-
#
|
4
|
-
# # app/controllers/posts_controller.rb
|
5
|
-
# class PostsController < ApplicationController
|
6
|
-
# # ...
|
7
|
-
# private
|
8
|
-
#
|
9
|
-
# def per_page
|
10
|
-
# 15
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
#
|
14
2
|
module ResourcesController::WillPaginateConcern
|
15
3
|
extend ActiveSupport::Concern
|
16
4
|
|
@@ -26,8 +14,16 @@ module Rao
|
|
26
14
|
|
27
15
|
def load_collection
|
28
16
|
options = { page: params[:page] }
|
29
|
-
options[:per_page] = per_page
|
17
|
+
options[:per_page] = per_page unless per_page.nil?
|
30
18
|
@collection = load_collection_scope.paginate(options)
|
31
19
|
end
|
20
|
+
|
21
|
+
def per_page
|
22
|
+
if [nil, 'all'].include?(params[:per_page])
|
23
|
+
nil
|
24
|
+
else
|
25
|
+
Rao::ResourcesController::Configuration.pagination_per_page_default
|
26
|
+
end
|
27
|
+
end
|
32
28
|
end
|
33
29
|
end
|
@@ -4,4 +4,12 @@ Rao::ResourcesController.configure do |config|
|
|
4
4
|
# default: config.resources_controller_base_class_name = '::ApplicationController'
|
5
5
|
#
|
6
6
|
config.resources_controller_base_class_name = '::ApplicationController'
|
7
|
+
|
8
|
+
# Set the pagination item count per page.
|
9
|
+
#
|
10
|
+
# Works for kaminari and will_paginate.
|
11
|
+
#
|
12
|
+
# default: config.pagination_per_page_default = 25
|
13
|
+
#
|
14
|
+
config.pagination_per_page_default = 25
|
7
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rao-resources_controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|