will_paginate を使っているのでしょうか?
私は will_paginate でなく kaminari を使っているので、的はずれな回答になっているかもしれません。
https://github.com/mislav/will_paginate より引用。
paginate in Active Record now returns a Relation
Post.where(:published => true).paginate(:page => params[:page]).order('id DESC')
the new, shorter page() method
Post.page(params[:page]).order('created_at DESC')
find_by でなく、 where をつかってみては?
こんな例もみつけました。
http://stackoverflow.com/questions/20454448/ruby-on-rails-search-order-limit-then-paginate
lang
1 def self.search(title, company, location_id, page)
2 if location_id
3 wages = Wage.where('title LIKE ? AND company LIKE ? AND location_id = ?', "%#{title}%", "%#{company}%", location_id).order('total DESC').limit(200).paginate(:page => page)
4 else
5 wages = Wage.where('title LIKE ? AND company LIKE ?', "%#{title}%", "%#{company}%").order('total DESC').limit(200).paginate(:page => page)
6 end
7 return wages
8 end
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2014/09/15 19:01