jasbur
1
how exactly would I apply paginate to a .find I have:
@posts = Post.find(:all,
:conditions => [ ‘(title) OR (body) LIKE ?’, ‘%’
- params[:query] + ‘%’],
:order => ‘end_date’)
How would I go about paginating the uoputed list? Something like 10 on a
page.
jasbur
2
I’m not sure if this is what u wanted…
_posts = Post.find(:all,
:conditions => [ ‘(title) OR (body) LIKE ?’, ‘%’+
params[:query] + ‘%’],
:order => ‘end_date’)
//or Post.count_by_sql
@post_pages = Paginator.new self, _posts.size, 10, @params[‘page’]
@posts = Post.find
:all,
:conditions => [ ‘(title) OR (body) LIKE ?’, ‘%’+
params[:query] + ‘%’],
:order => ‘end_date’
:limit => @post_pages.items_per_page,
:offset => @post_pages.current.offset