[PATCH conductor] Updates filter_table to display pagination links whenever paginated.
Jirka Tomasek
jtomasek at redhat.com
Wed Sep 12 15:46:50 UTC 2012
On 09/12/2012 01:18 AM, Matt Wagner wrote:
> Apparently in newer versions of ActiveRecord with will_paginate,
> calling .paginate will sometimes return an ActiveRecord::Relation
> instead of the WillPaginate::Collection we're used to. That broke
> our pagination links. See this link for extra info:
> http://rubydoc.info/gems/will_paginate/3.0.2/file/README.md
>
> Lacking an apparent clear way to check if a set is paginated
> or not, we changed the conditional here to see if the set
> responds to the total_pages method that will_paginate adds to
> the set.
> ---
> src/app/views/layouts/_filter_table.html.haml | 9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/src/app/views/layouts/_filter_table.html.haml b/src/app/views/layouts/_filter_table.html.haml
> index 453266c..bb93950 100644
> --- a/src/app/views/layouts/_filter_table.html.haml
> +++ b/src/app/views/layouts/_filter_table.html.haml
> @@ -26,5 +26,12 @@
> %fieldset.options
> = yield form_footer
>
> -- if rows.is_a?(WillPaginate::Collection)
> +-# With the latest ActiveRecord + will_paginate versions, we
> +-# sometimes get back an ActiveRecord::Relation after pagination,
> +-# so we can't just check if it's a WillPaginate::Collection.
> +-# http://rubydoc.info/gems/will_paginate/3.0.2/file/README.md
> +-# Checking for the methods will_paginate adds is the best way
> +-# we have been able to find to check if we're viewing a paginated
> +-# collection or not.
> +- if rows.respond_to?(:total_pages)
> = render_pagination(rows)
ACK, fixes the issue, all tests green.
Jirka
More information about the aeolus-devel
mailing list