diff options
author | Uģis Ozols <ugis.ozolss@gmail.com> | 2011-07-27 22:41:42 +0300 |
---|---|---|
committer | Uģis Ozols <ugis.ozolss@gmail.com> | 2011-07-27 22:41:42 +0300 |
commit | 109184377f96db0530228cb3a8c38fe042e710c0 (patch) | |
tree | 381fbe74bbc70ea899665411e40677599611bdec /app/controllers/refinery | |
parent | 164dc27a42876efdbd14db9e2d14311b4c119e52 (diff) | |
download | refinerycms-blog-109184377f96db0530228cb3a8c38fe042e710c0.tar.gz refinerycms-blog-109184377f96db0530228cb3a8c38fe042e710c0.tar.bz2 refinerycms-blog-109184377f96db0530228cb3a8c38fe042e710c0.zip |
Move per_page pagination stuff into model to dry up posts controller.
Diffstat (limited to 'app/controllers/refinery')
-rw-r--r-- | app/controllers/refinery/blog/posts_controller.rb | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb index f055797..408359f 100644 --- a/app/controllers/refinery/blog/posts_controller.rb +++ b/app/controllers/refinery/blog/posts_controller.rb @@ -54,18 +54,16 @@ module Refinery date = "#{params[:month]}/#{params[:year]}" @archive_date = Time.parse(date) @date_title = @archive_date.strftime('%B %Y') - @blog_posts = BlogPost.live.by_archive(@archive_date).paginate({ - :page => params[:page], - :per_page => Refinery::Setting.find_or_set(:blog_posts_per_page, 10) - }) + @blog_posts = Refinery::BlogPost.live + .by_archive(@archive_date) + .page(params[:page]) else date = "01/#{params[:year]}" @archive_date = Time.parse(date) @date_title = @archive_date.strftime('%Y') - @blog_posts = Refinery::live.by_year(@archive_date).paginate({ - :page => params[:page], - :per_page => Refinery::Setting.find_or_set(:blog_posts_per_page, 10) - }) + @blog_posts = Refinery::BlogPost.live + .by_year(@archive_date) + .page(params[:page]) end respond_with (@blog_posts) end @@ -75,7 +73,6 @@ module Refinery @tag_name = @tag.name @blog_posts = Refinery::BlogPost.tagged_with(@tag_name) .page(params[:page]) - .per(Refinery::Setting.find_or_set(:blog_posts_per_page, 10)) end protected @@ -94,7 +91,6 @@ module Refinery @blog_posts = Refinery::BlogPost.live .includes(:comments, :categories) .page(params[:page]) - .per(Refinery::Setting.find_or_set(:blog_posts_per_page, 10)) end def find_tags |