Module: TrustyCms::Pagination::Controller
- Included in:
- SiteController
- Defined in:
- lib/trusty_cms/pagination/controller.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#configure_pagination ⇒ Object
for inclusion into public-facing controllers.
- #pagination_parameters ⇒ Object
Class Method Details
.included(base) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/trusty_cms/pagination/controller.rb', line 25 def self.included(base) base.class_eval do helper_method :pagination_parameters before_action :configure_pagination end end |
Instance Method Details
#configure_pagination ⇒ Object
for inclusion into public-facing controllers
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/trusty_cms/pagination/controller.rb', line 6 def configure_pagination # unconfigured parameters remain at will_paginate defaults # will_paginate controller options are not overridden by tag attribetus WillPaginate::ViewHelpers.[:param_name] = TrustyCms::Config['pagination.param_name'].to_sym unless TrustyCms::Config['pagination.param_name'].blank? WillPaginate::ViewHelpers.[:per_page_param_name] = TrustyCms::Config['pagination.per_page_param_name'].blank? ? :per_page : TrustyCms::Config['pagination.per_page_param_name'].to_sym # will_paginate view options can be overridden by tag attributes %i[class previous_label next_label inner_window outer_window separator container].each do |opt| WillPaginate::ViewHelpers.[opt] = TrustyCms::Config["pagination.#{opt}"] unless TrustyCms::Config["pagination.#{opt}"].blank? end end |
#pagination_parameters ⇒ Object
18 19 20 21 22 23 |
# File 'lib/trusty_cms/pagination/controller.rb', line 18 def pagination_parameters { page: params[WillPaginate::ViewHelpers.[:param_name]] || 1, per_page: params[WillPaginate::ViewHelpers.[:per_page_param_name]] || TrustyCms::Config['pagination.per_page'] || 20, } end |