我有一个非常基本的模型,称为 Review(基本上只是一个 ID 序列和一些文本列),我正在为它制作一个简单的分页系统。以下代码:
Review.all(:limit => per_page, :offset => offset, :order => [ :id.asc ])
如果偏移量为 0,则返回正确的对象,但如果偏移量为其他值,则会出现问题。偏移量 > 0 时,代码:
reviews = Review.all(:offset => offset, :limit => per_page);
p reviews
p reviews.count
返回
[#<Review @id=11 @created_at=<not loaded> @rating=<not loaded> @title=<not loaded> @text= <not loaded> @name=<not loaded> @from=<not loaded> @stay_date=<not loaded> @helpful=0 @not_helpful=0 @response=<not loaded>>, #<Review @id=12 @created_at=<not loaded> @rating=<not loaded> @title=<not loaded> @text=<not loaded> @name=<not loaded> @from=<not loaded> @stay_date=<not loaded> @helpful=0 @not_helpful=0 @response=<not loaded>>, #<Review @id=13 @created_at=<not loaded> @rating=<not loaded> @title=<not loaded> @text=<not loaded> @name=<not loaded> @from=<not loaded> @stay_date=<not loaded> @helpful=0 @not_helpful=0 @response=<not loaded>>, #<Review @id=14 @created_at=<not loaded> @rating=<not loaded> @title=<not loaded> @text=<not loaded> @name=<not loaded> @from=<not loaded> @stay_date=<not loaded> @helpful=0 @not_helpful=0 @response=<not loaded>>, #<Review @id=15 @created_at=<not loaded> @rating=<not loaded> @title=<not loaded> @text=<not loaded> @name=<not loaded> @from=<not loaded> @stay_date=<not loaded> @helpful=0 @not_helpful=0 @response=<not loaded>>]
0
这怎么样?它正在寻找对象,但无法计算它们?