ruby on rails 3 - kaminari: undefined method `paginate' for #<ActiveRecord::Relation:0x007f9933670ab0> -
in controller, have:
@bills = bill.where(:param1 => x, :param2 => y).sort_by {|u| u.created_at}.reverse.paginate(:page => params[:page])
and above-mentioned error when seek render. getting rid of where, sort , reverse clauses gets rid of problem need them. how can have both?
when phone call sort_by {|u| u.created_at}
, fetch info db array , sort in ruby side.
if want paginate ruby array info seek this:
@bills = kaminari.paginate_array(bill.where(:param1 => x, :param2 => y)).page(params[:page]).per(per_page_records)`
but improve way sort yours info in db query
@bills = bill.where(:param1 => x, :param2 => y).order("created_at desc").paginate(:page => params[:page])
ruby-on-rails-3 kaminari
No comments:
Post a Comment