Skip to content
Extraits de code Groupes Projets
Valider b7c3f93d rédigé par Raphael Sofaer's avatar Raphael Sofaer
Parcourir les fichiers

Use delegation in PostFake, use render => :collection in stream

parent 6e7bdf7c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -4,8 +4,13 @@
- if posts.length > 0
- for post in posts
-# for post in posts
= render 'shared/stream_element', :post => post, :all_aspects => @all_aspects, :commenting_disabled => defined?(@commenting_disabled)
= render :partial => 'shared/stream_element',
:collection => posts,
:as => :post,
:locals => {:all_aspects => @all_aspects,
:commenting_disabled => defined?(@commenting_disabled)}
- else
= render 'aspects/no_posts_message', :post_count => posts.length
class PostsFake
attr_reader :people_hash, :post_fakes
def method_missing(method, *args, &block)
@post_fakes.send(method, *args, &block)
end
delegate :length, :each, :to_ary, :to => :post_fakes
def initialize(posts)
person_ids = []
posts.each do |p|
posts.each do |p|
person_ids << p.person_id
p.comments.each do |c|
person_ids << c.person_id
......@@ -19,9 +16,9 @@ class PostsFake
people.each{|person| @people_hash[person.id] = person}
@post_fakes = posts.map do |post|
f = Fake.new(post, self)
f = Fake.new(post, self)
f.comments = post.comments.map do |comment|
Fake.new(comment, self)
Fake.new(comment, self)
end
f
end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter