will paginate di rails 3 memiliki beberapa perbedaan, jika di rails 2 "paginate" hampir sama dengan "find", tetapi di rails 3 berbeda.
Contoh Script:
conditions = ["condition what!"]
order_by = ["order by what!"]
a = current_user.a
for rails 2:
@A = a.paginate(:page => params[:page], :per_page => @per_page, :conditions => conditions, :order => order_by)
for rails 3:
a = current_user.a
@A = a.find(:all, :conditions => conditions, :order => order_by).paginate(:page => params[:page], :per_page => @per_page)
jika condition atau order tidak dibuat variabel terpisah maka kita bisa menggunakan where atau order sesuai ketentuan di rails 3
Contoh Script:
conditions = ["condition what!"]
order_by = ["order by what!"]
a = current_user.a
for rails 2:
@A = a.paginate(:page => params[:page], :per_page => @per_page, :conditions => conditions, :order => order_by)
for rails 3:
a = current_user.a
@A = a.find(:all, :conditions => conditions, :order => order_by).paginate(:page => params[:page], :per_page => @per_page)
jika condition atau order tidak dibuat variabel terpisah maka kita bisa menggunakan where atau order sesuai ketentuan di rails 3
No comments:
Post a Comment