If I understand what you are trying to do, you want the first page to show results from the last 10 days, the next page to show results from the previous 10 days, etc. If each day only has one result (or every page has the same number of results), then just add ':per_page => 10 (or whatever number of records you want on each page)' to the #paginate call to tell paginate to return results for 10 days. If each day has a variable number of results, will_paginate is not well-suited to what you are trying to do. Will_paginate is oriented towards partitioning your results into groups of 'n' and efficiently moving among groups. If you still want to use will_paginate, change your query to produce one record per day, set :per_page => 10, and find a way in your view to expand each day into all of it's results.
> If mastertest is a model
> Mastertest.select("code_ver, result").
> where("code_ver NOT LIKE '%DevBld%'").
> where("date >= DATE_SUB( (CURDATE()) , INTERVAL 90 DAY)").
> order("date DESC")
> You can then call the .paginate on this:
> Not sure what you mean by "ow I want to paginate my
>> results such that each page displays only rows from the last 10 days"
> If you meant you want to only select the records then add another .where()
> On Thu, Nov 1, 2012 at 10:17 PM, Sagar Vikani <sagarvikani2...@gmail.com> wrote:
>> I have a SQL query which looks like this:
>> SELECT code_ver, result FROM mastertest WHERE code_ver NOT LIKE '%DevBld%'
>> AND date >= DATE_SUB( (CURDATE()) , INTERVAL 90 DAY) ORDER BY date DESC;
>> This query gives me results from the last 90 days. Now I want to paginate my
>> results such that each page displays only rows from the last 10 days.
>> Can someone build a query which I can use with the 'will_paginate' ?
>> --
>> You received this message because you are subscribed to the Google Groups
>> "will_paginate" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/will_paginate/-/bN0Aizjmv-oJ.
>> To post to this group, send email to will_paginate@googlegroups.com.
>> To unsubscribe from this group, send email to
>> will_paginate+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/will_paginate?hl=en.
> --
> You received this message because you are subscribed to the Google Groups "will_paginate" group.
> To post to this group, send email to will_paginate@googlegroups.com.
> To unsubscribe from this group, send email to will_paginate+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/will_paginate?hl=en.