Skip to content

Commit

Permalink
refactor pagination_for to set to_i on depagination_limit and use con…
Browse files Browse the repository at this point in the history
…tent_tag helper so the upgrade to rails 2.3.8 goes smoothly
  • Loading branch information
saturnflyer committed Jun 14, 2010
1 parent 37e4829 commit 424fb07
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/helpers/application_helper.rb
Expand Up @@ -227,10 +227,8 @@ def pagination_for(list, options={})
depaginate = options.delete(:depaginate) # supply :depaginate => false to omit the 'show all' link
depagination_limit = options.delete(:max_per_page) # supply :max_per_page => false to include the 'show all' link no matter how large the collection
html = will_paginate(list, will_paginate_options.merge(options))
if depaginate && list.total_pages > 1 && (!depagination_limit || list.total_entries <= depagination_limit)
html << %{<div class="depaginate">}
html << link_to("show all", :pp => list.total_entries)
html << %{</div>}
if depaginate && list.total_pages > 1 && (!depagination_limit.blank? || list.total_entries <= depagination_limit.to_i)
html << content_tag(:div, link_to("show all", :pp => list.total_entries), :class => 'depaginate')
end
html
end
Expand Down

1 comment on commit 424fb07

@spanner
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tidier. Thank you.

Please sign in to comment.