Limiting records in recursion
15: - 开发者_StackOverflow社区for findlist in @user.findlists
16: =findlist.name
17: %div
18: - for product in findlist.products
19: = image_tag(product.photo.url(:small))
I am looking at line 18. Is there a way to limit findlist.products to only 3 records without putting some kind of counter?
I am using Rails 2.3.8
is limited a method in your model? you can always append a find method in rails 3 with limit(n)
so in your case if that is a find method
for product in findlist.products.limit(3)
if you're not using rails 3:
for product in findlist.products.find(:all, :limit => 3)
精彩评论