I wish to send to the client only the 20 recent Post objects.
How do i that? I'm new to rails so ill appreciate your advice very much. thanks.
Just do:
@posts = Post.all(:order => 'created_at desc', :limit => 20)
respond_to do |format|
format.json
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.