is it possible to combine will_paginate with find_by_sql?

Posted by Tam on Stack Overflow See other posts from Stack Overflow or by Tam
Published on 2010-03-29T04:56:34Z Indexed on 2010/03/29 5:03 UTC
Read the original article Hit count: 170

In my rails application I want to use will_paginate plugin to paginate on my query. Is that possible? I tried doing something like this but it didn't work:

@users =     User.find_by_sql("
    SELECT u.id, u.first_name, u.last_name, 
     CASE 
      WHEN r.user_accepted =1 AND (r.friend_accepted =0 || r.friend_accepted IS NULL)
       .........").paginate(
                  :page => @page, :per_page => @per_page, 
                  :conditions => conditions_hash,
                  :order => 'first_name ASC')

If not, can you recommend a way around this or a way that might work as I don't want to write my own pagination.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about will-paginate