Class: SimpleDiscussion::BootstrapLinkRenderer

Inherits:
WillPaginate::ActionView::LinkRenderer
  • Object
show all
Defined in:
lib/simple_discussion/will_paginate.rb

Overview

This code serves two purposes

  1. It patches will_paginate to work with scoped and mounted Rails engines by adding in the url_builder option

  2. It adds Bootstrap 4 styling to will_paginate

Instance Method Summary collapse

Instance Method Details

#url(page) ⇒ Object

This method adds the ‘url_builder` option so we can pass in the mounted Rails engine’s scope for will_paginate



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/simple_discussion/will_paginate.rb', line 12

def url(page)
  @base_url_params ||= begin
    url_params = merge_get_params(default_url_params)
    merge_optional_params(url_params)
  end

  url_params = @base_url_params.dup
  add_current_page_param(url_params, page)

  # Add optional url_builder support
  (@options[:url_builder] || @template).url_for(url_params)
end