Sha256: 922ad120d168bf2e63b8c9519ecaacf1ee122c33d6a66b91a5b661e103645b93
Contents?: true
Size: 894 Bytes
Versions: 3
Compression:
Stored size: 894 Bytes
Contents
class PostsController < Ecrire::ThemeController helper_method :post, :posts def index @posts = posts.published.includes(:titles).order('published_at DESC').page(params[:page]).per(params[:per]) if params[:page] == 1 @latest = @posts.first @posts = @posts.where.not(id: @latest.id) end @tags = Tag.all super end def show redirect_to :root and return if post.nil? redirect_to :root and return unless post.published? if post.titles.first != @title redirect_to theme.post_path(post.year, post.month, post), status: :moved_permanently end @suggestions = Post.published.limit(5).where.not(id: post.id) end protected def posts @posts ||= Post.published.page(params[:page]).per(params[:per]).order('published_at DESC') end def post @title ||= Title.find_by_slug(params[:id]) @post ||= @title.post end end
Version data entries
3 entries across 3 versions & 1 rubygems