Let me take this one Pat. I'm sure you have more on your plate right now.

params[:page] sets the offset when searching/finding records.

Let's say Story.search returns 20 results, numbered 1-20 accordingly.
 Adding a :page => 2, :per_page => 9 option
would set the offset to 9 and would return results 10-18.  Setting :page =>
3 would return 19-20.

In your query, you're saying that you can only have 9 records per page, and
you want the page with page number equal to params[:page]

I Hope this shed some light.

On Thu, Sep 2, 2010 at 10:57 PM, Seth Gitner <[email protected]> wrote:

> Ok I got it to work -- Many thanks for your help.
>
>
>  @stories = Story.search params[:search], :page => params[:page],
> :per_page => 9
>
>  here is what I came up with.
>
> Is there any way that you can explain each part of this for me like
> what does params[:page] mean? in the line?
>
> thx,
>
> sg
>
>
>
>
> On Thu, Sep 2, 2010 at 1:41 AM, Pat Allan <[email protected]>
> wrote:
> > Hi Seth
> >
> > Your paginate arguments should be part of the search call - you don't
> > need to make two calls:
> >
> >  Story.search params[:search], :page => params[:page], :order =>
> > 'published_at DESC', :per_page => 9
> >
> > Of course, for your :order option to work, you'll need published_at to
> > be an attribute.
> >
> > Hope this helps
> >
> > Cheers
> >
> > --
> > Pat
> >
> > On 9/2/2010, "sethg" <[email protected]> wrote:
> >
> >>I am having a problem with ts and will_paginate.
> >>
> >>TS works when I do not put my the story.paginate code in -- when i put
> >>that code in it kills my search -- it paginates but does not change
> >>content, can someone assist?
> >>
> >>thx,
> >>
> >>seth
> >>
> >>here is my controller
> >>
> >>PAGINATION WORKS BUT SEARCH DOES NOT
> >>def index
> >>@stories = Story.search(params[:search])
> >>@stories = Story.paginate({:page => params[:page],:order =>
> >>"published_at DESC",:per_page => 9})
> >>
> >>SEARCH WORKS BUT PAGINATION DOES NOT
> >>def index
> >>@stories = Story.search(params[:search])
> >>#...@stories = Story.paginate({:page => params[:page],:order =>
> >>"published_at DESC",:per_page => 9})
> >>
> >>PAGINATION WORKS BUT SEARCH DOES NOT
> >>def index
> >>#...@stories = Story.search(params[:search])
> >>@stories = Story.paginate({:page => params[:page],:order =>
> >>"published_at DESC",:per_page => 9})
> >>
> >>Please assist I really want to get my site launched soon.
> >>
> >>Seth
> >>
> >>--
> >>You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> >>To post to this group, send email to [email protected].
> >>To unsubscribe from this group, send email to
> [email protected]<thinking-sphinx%[email protected]>
> .
> >>For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> [email protected]<thinking-sphinx%[email protected]>
> .
> > For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<thinking-sphinx%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
>
>


-- 
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to