Commit 3869e431aa083d927d7560e220820632f17665a0

Authored by Rodrigo Souto
2 parents d040dc77 043b4c32

Merge branch 'blog-translations-memory-overload' into stable

app/controllers/public/content_viewer_controller.rb
@@ -79,11 +79,17 @@ class ContentViewerController < ApplicationController @@ -79,11 +79,17 @@ class ContentViewerController < ApplicationController
79 @page.posts 79 @page.posts
80 end 80 end
81 81
82 - if @page.blog? && @page.display_posts_in_current_language?  
83 - posts = posts.native_translations.all(Article.display_filter(user, profile)).map{ |p| p.get_translation_to(FastGettext.locale) }.compact  
84 - end 82 + #FIXME Need to run this before the pagination because this version of
  83 + # will_paginate returns a will_paginate collection instead of a
  84 + # relation.
  85 + blog_with_translation = @page.blog? && @page.display_posts_in_current_language?
  86 + posts = posts.native_translations if blog_with_translation
85 87
86 @posts = posts.paginate({ :page => params[:npage], :per_page => @page.posts_per_page }.merge(Article.display_filter(user, profile))) 88 @posts = posts.paginate({ :page => params[:npage], :per_page => @page.posts_per_page }.merge(Article.display_filter(user, profile)))
  89 +
  90 + if blog_with_translation
  91 + @posts.replace @posts.map{ |p| p.get_translation_to(FastGettext.locale) }.compact
  92 + end
87 end 93 end
88 94
89 if @page.folder? && @page.gallery? 95 if @page.folder? && @page.gallery?