RailsCasts Pro episodes are now free!

Learn more or hide this

Zachary Wright's Profile

GitHub User: zacharyw

Comments by Zachary Wright


Small gotcha if anyone gets caught up on this...if you are attempting to paginate an ActiveRecord relation that has had the includes method called on it, and you include another table with a column name that is the same as the table you're paginating (like created_at), and you're trying to order on that column, kaminari can't figure it out.

You have to do something like this:
@posts = Post.order("posts.created_at DESC").page(params[:page]).per(5).includes(:comments)