Module: ActiveTracker::PaginationHelper

Defined in:
app/helpers/active_tracker/pagination_helper.rb

Instance Method Summary collapse

Instance Method Details

#insert_page_to_url(url, page) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/active_tracker/pagination_helper.rb', line 3

def insert_page_to_url(url, page)
  if url.include?("?")
    if url[/[?&]page=/]
      url = url.gsub(/([?&]page)=\d+/, "\\1=#{page}")
    else
      url += "&page=#{page}"
    end
  else
    url += "?page=#{page}"
  end
  url
end