refactor list view (PR #131)

  • move “next page” link to helper
  • use content_tag_for to replace for each and <tr> , it boost performance.

GitHub

Just curious: any benchmarks regarding the boost provided by content_tag_for ?

Is this a typo? in app/views/list/list.erb render_topic_posts_count

vs

in app/helpers/topics_helper.rb render_topic_posts_coount

1 Like

@ZogStrip

Hi, you can try this code

<% @posts.each do |post %>
<li> <%= post.titlew %> </li>
<% end %>

and

<%= content_tag_for( :li, @posst ) do |post| %>
 <%= post.title %> 
<% end %>

the check the log

Is the .sub necessary? Can’t a link be passed a format instead?

it’s the original design. so it’s up to you

I think it shouldn’t be there, but if it’s the original way of doing things we can accept this and fix that later in a follow up.

@eviltrout .sub is from here …

There is a typo here as well: list.topics.lenth. But why pass in the number of topics as an argument? Wouldn’t it be easier to call list.topics.length in the helper?

if you call topics.length, it wouldn’t have cache …

This would become query in the helper :confused:

Any idea why it can’t be merged?

okay…now i rebase master…