eager load author and profile for comments
This commit is contained in:
parent
f3183a11e1
commit
3296477531
2 changed files with 4 additions and 2 deletions
|
|
@ -32,6 +32,8 @@ class Comment < ActiveRecord::Base
|
||||||
|
|
||||||
serialize :youtube_titles, Hash
|
serialize :youtube_titles, Hash
|
||||||
|
|
||||||
|
scope :including_author, includes(:author => :profile)
|
||||||
|
|
||||||
before_save do
|
before_save do
|
||||||
self.text.strip! unless self.text.nil?
|
self.text.strip! unless self.text.nil?
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
%ul.comments{:class => ('loaded' if post.comments.size <= 3)}
|
%ul.comments{:class => ('loaded' if post.comments.size <= 3)}
|
||||||
-if post.comments.size > 3 && !comments_expanded && ! all_comments?
|
-if post.comments.size > 3 && !comments_expanded && ! all_comments?
|
||||||
= render :partial => 'comments/comment', :collection => post.comments.last(3), :locals => {:post => post}
|
= render :partial => 'comments/comment', :collection => post.comments.last(3).including_author, :locals => {:post => post}
|
||||||
-else
|
-else
|
||||||
= render :partial => 'comments/comment', :collection => post.comments, :locals => {:post => post}
|
= render :partial => 'comments/comment', :collection => post.comments.including_author, :locals => {:post => post}
|
||||||
|
|
||||||
- unless commenting_disabled?(post)
|
- unless commenting_disabled?(post)
|
||||||
.new_comment_form_wrapper{:class => comment_form_wrapper_class(post)}
|
.new_comment_form_wrapper{:class => comment_form_wrapper_class(post)}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue