From 08a790c89e5bf6eb744410338c3bfe1c80a6000b Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Fri, 29 Mar 2013 15:42:37 +0000 Subject: [PATCH] Count posts per layer in the view not the controller --- app/controllers/layers_controller.rb | 3 --- app/views/layers/show.html.haml | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/layers_controller.rb b/app/controllers/layers_controller.rb index fbc631e..e95fe31 100644 --- a/app/controllers/layers_controller.rb +++ b/app/controllers/layers_controller.rb @@ -19,9 +19,6 @@ class LayersController < ApplicationController @feed = Feed.new @feed.new_layer_id = @layer.id - @layer_posts = 0 - @layer.feeds.each { |f| @layer_posts += f.posts.size } - respond_to do |format| format.html # show.html.erb format.json { render json: @layer } diff --git a/app/views/layers/show.html.haml b/app/views/layers/show.html.haml index 562e29b..2187688 100644 --- a/app/views/layers/show.html.haml +++ b/app/views/layers/show.html.haml @@ -24,8 +24,9 @@ %th %th %th - + - @layer_posts = 0 - @layer.feeds.each do |f| + - @layer_posts += f.posts.count %tr %td .feed_title