首先的代码:
# matches/index.html.haml
%ul.match_list
- @matches.each do |match|
%li
=render match
# matches/_match.html.haml
%li
=match.id
Completed 200 OK in 665ms (Views: 496.3ms | ActiveRecord: 142.1ms)
速度慢得要死。
第二段代码:
# matches/index.html.haml
%ul.match_list
- @matches.each do |match|
%li
=match.id
Completed 200 OK in 196ms (Views: 30.0ms | ActiveRecord: 134.6ms)
效果更好了。
为什么不使用 partial 时速度会快很多呢?