activerecord-hackery / meta_search

Object-based searching (and more) for simply creating search forms. Not currently maintained.
http://erniemiller.org/2013/11/17/anyone-interested-in-activerecord-hackery/
MIT License
903 stars 140 forks source link

per_page parameter ignored when defined on model (will_paginate) #27

Closed brendon closed 13 years ago

brendon commented 13 years ago

Hi Ernie,

I can't get over how great this gem is! Such a time saver and so flexible! :)

I've run into a strange problem with using will_paginate in combination with meta_search. If I define the per_page class attribute like so:

cattr_reader :per_page
@@per_page = 2

and then do a standard search:

@search = Warranty.search(params[:search])
@warranties = @search.paginate(:page => params[:page])

The per_page setting gets ignored. I tried defining the per_page settings in the actual .paginate call and it works well there, so somewhere along the line it's getting filtered out. I've check and confirmed that the per_page class attribute is working on a model that doesn't use meta-search to get the records.

Hope that helps :D

ernie commented 13 years ago

Sorry for the delay. As you might know, my focus has been on other libraries lately. I'm not sure why this would be, since we create a relation the same way you do when you call paginate on a relation directly. Are you paginating directly against the base model, in your working test, or are you doing a paginate against an actual relation?

brendon commented 13 years ago

Hi Ernie, that's no problem at all :D

I was paginating against the base model:

Warranty.all.paginate

So you're thinking it could be a problem with will_paginate and relations? :)

ernie commented 13 years ago

Most probably, yes.

Sent from my iPhone

On Jun 22, 2011, at 6:41 PM, brendon reply@reply.github.com wrote:

Hi Ernie, that's no problem at all :D

I was paginating against the base model:

Warranty.all.paginate

So you're thinking it could be a problem with will_paginate and relations? :)

Reply to this email directly or view it on GitHub: https://github.com/ernie/meta_search/issues/27#issuecomment-1421718

brendon commented 13 years ago

Very good :) It turned out to not be a problem for be because 30 records per page was fine. So I'll just leave it as is and close the issue :D

Thanks heaps :) Have a great day!

Brendon

On Thu, Jun 23, 2011 at 10:47 AM, ernie < reply@reply.github.com>wrote:

Most probably, yes.

Sent from my iPhone

On Jun 22, 2011, at 6:41 PM, brendon reply@reply.github.com wrote:

Hi Ernie, that's no problem at all :D

I was paginating against the base model:

Warranty.all.paginate

So you're thinking it could be a problem with will_paginate and relations? :)

Reply to this email directly or view it on GitHub: https://github.com/ernie/meta_search/issues/27#issuecomment-1421718

Reply to this email directly or view it on GitHub: https://github.com/ernie/meta_search/issues/27#issuecomment-1421759