Paginate!! passing params[] for conditions for DB search

I have stuck on pagination by passing values from a text_field for
searching a db, It works on the first page and it throws an SQL error
while clicking the second page. Below is my code, guys definetly help
needed, thanks in advance.

i pass search params from the text_field in .rhtml

conditions = @params['search'].to_s.split(' ').collect {|query_search|
"requirements.position_title LIKE '%#{query_search}%'"}.join(' OR ')

requirement = Requirement.find_all
@requirement_pages, @requirements = paginate :requirements, :per_page =>
5, :order => 'opening_date DESC', :conditions => conditions

error i get is about count(*) which i dont use anywhere in the code. and
The db config of mine is MySQL server 5.0

Mysql::Error: #42000You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near ')' at line 1: SELECT count(*) AS count_all FROM
requirements WHERE ()

Looks like on page 2, @params['search'] doesn't contain any spaces so there's nothing to split, collect, or join so 'conditions' is nil resulting in "WHERE ()" which is invalid.

Why @params['search'] instead of params[:search]?

Also, why are you finding all the requirements right before paginating? Seems like a redundant effort?

Check your logs to see what rails sees in it's params when you hit page two...

-philip

Hi

Is there a way to have 'rake stats' read my specs as tests and log my
specs' lines of code accordingly?

Thanks in advance.
Gustav Paul

From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-
talk@googlegroups.com] On Behalf Of Gustav Paul
Sent: 12 December 2006 13:18
To: rubyonrails-talk@googlegroups.com
Subject: [Rails] rake stats not picking up RSpec

Hi

Is there a way to have 'rake stats' read my specs as tests and log my
specs' lines of code accordingly?

Try:

rake spec:statsetup

That should setup stats to use rspec.

hth