1
在posts控制器對象包含所有活動的帖子:檢查下一個活動的記錄存在
@posts = Post.where(status: 'active').order(:name)
在查看此對象被重複,我必須執行基於下一篇文章存在的一些操作。
<% @posts.each do |post|
if post.next_post_exists?
# do something.
else
# delete author.
end
end
%>
那麼,什麼是檢查接下來的文章中存在的最好方法?
def next_post_exists?
#TODO
end