✓ I'm available for hire! Check out my open source work on Github or drop me an email

Douglas F Shearer

Rails Plugin: Will_Paginate_Search

THIS PLUGIN IS NOW DEPRECATED

The features provided by this plugin are now part of the Acts_as_indexed plugin it originally supported.

This plugin allows my acts_as_indexed indexed search plugin to interoperate with the will_paginate pagination plugin.

Install

Prerequisites

For this to work you’ll need the following two plugins…

Install will_paginate_search

./script/plugin install http://svn.douglasfshearer.com/rails/plugins/will_paginate_search

Setup

Follow through the instructions on setting up acts_as_search in the readme, and give the will_paginate readme a read over too.

Searching With Pagination

First argument is the search query (can be a GET variable or anything else), and after that it takes all the standard will_paginate arguments.

@images = Image.paginate_search 'girl', :page => 1, :per_page => 5

Other Stuff

Problems, Comments, Suggestions?

All of the above are most welcome. dougal.s@gmail.com

Credits

Douglas F Shearer

Donate

If you find this plugin useful, please consider a "donation (Paypal) ":https://www.paypal.com/cgi-bin/webscr?cmd=xclick&business=dougal%2es%40gmail%2ecom&item_name=Douglas%20F%20Shearer&buyer_credit_promo_code=&buyer_credit_product_category=&buyer_credit_shipping_method=&buyer_credit_user_address_change=&page_style=Primary&no_shipping=0&return=http%3a%2f%2fdouglasfshearer%2ecom&cancel_return=http%3a%2f%2fdouglasfshearer%2ecom&no_note=1&cn=I%20am%20donating%20because%2e%2e%2e&tax=0&currencycode=GBP&lc=GB&bn=PP%2dDonationsBF&charset=UTF%2d8 to show your support!

 
 

Comments

Gravatar

Chris

December 31 2007 04:37

I installed this plugin, will_paginate and your acts_as_indexed plugin. The pagination and acts_as_index work beautifully but, this one keep throwing me an error:

`per_page` setting cannot be less than 1 (0 given)

Using your example:
@images = Image.paginate_search 'girl', :page => 1, :per_page => 5

Modified to look like:
@results = Business.paginate_search params[:search][:for], :page => 1, :per_page => 5

Looking into the will_paginate_search.rb file I cannot seem to find the problem. Can't find it in will_paginate collections.rb on line 38 either...

Any ideas, I am a novice at ruby and ruby on rails?

Gravatar

Douglas F Shearer

January 11 2008 10:00

The plugin has now been updated to reflect the latest version of will_paginate, and prevent the error you were seeing.

Thanks for informing me of this.

Gravatar

Chris

January 12 2008 03:34

Thank you, kind sir! It works wonderfully!

Gravatar

D William

March 26 2008 13:46

When I try to go on next page (page 2) it says I have nil object when I didn't expect it.

Whats wrong?

Gravatar

Dan

April 22 2008 01:51

Douglas, these are incredibly useful plugins and I just wanted to say thank you.

Also Steve - your updates were great, fixed all my problems.

Thank you both.

Gravatar

Stephen Bartholomew

February 27 2008 20:53

Hey Douglas,

Loving your acts_as_indexed plugin, but I had a few problems getting will_paginate_search working.

The main issues seem to stem from the use of the wp_parse_options! method which as now changed to wp_parse_options in will_paginate.

I also had an issue where the :page and :per_page options were being passed to the find_with_index method causing an 'unknown keys' error from AR.

Anyway, I've pasted my changes here: http://pastie.cab...

These are just some quick patching, but hopefully they'll help!

Cheers,

Steve

Gravatar

Douglas F Shearer

April 22 2008 10:25

Thanks Dan.

Steve's patch has now been rolled into the plugin, so the previous issues should no longer be apparent.

Sorry it took so long, I missed that comment altogether.

Gravatar

Dan

April 30 2008 04:23

D William - I'm willing to bet that the issue you are running into is that your form is being submitted as a POST (Rails default) and not a GET. I had the same issue.

I changed my form tag from
'browse', :action => 'search' do %> to 'search', :controller => 'browse'}, {:method => 'get'}) do %>

Now my form is being submitted as a GET and problem solved. I also recommend not using the default Rails form submit tag, but an actual HTML tag, . This will remove the useless Commit parameter from the URL.

Add Your Comments

Commenting is closed for this entry