Take a query out of the views

This commit is contained in:
Raphael 2010-11-25 22:52:24 -05:00
parent 33ba00377e
commit 690951dcd1
4 changed files with 5 additions and 5 deletions

View file

@ -13,7 +13,7 @@ module SocketsHelper
begin
user = User.find_by_id uid
if object.is_a? Post
v = render_to_string(:partial => 'shared/stream_element', :locals => {:post => object, :current_user => user})
v = render_to_string(:partial => 'shared/stream_element', :locals => {:post => object, :current_user => user, :aspects => user.aspects})
elsif object.is_a? Person
v = render_to_string(:partial => type_partial(object), :locals => {:single_aspect_form => opts[:single_aspect_form], :person => object, :aspects => user.aspects, :current_user => user})
elsif object.is_a? Comment

View file

@ -3,5 +3,5 @@
-# the COPYRIGHT file.
%ul{:class => 'stream', :id => 'main_stream'}
- for post in posts
= render 'shared/stream_element', :post => post
- for post in @posts
= render 'shared/stream_element', :post => post, :aspects => @aspects

View file

@ -17,7 +17,7 @@
- if post.public?
%li= t('the_world')
- else
- for aspect in current_user.aspects_with_post( post.id )
- for aspect in aspects.select{|a| a.post_ids.include?(post.id)}
%li= link_to aspect.name, aspect
.right

View file

@ -49,7 +49,7 @@ describe AspectsController do
it 'takes time' do
Benchmark.realtime{
get :index
}.should < 0
}.should < 3
end
end
end