Sha256: 00e2bef47f4a37364cdc1efe11eecabc2e502b4643bf1c7649b3b6b6594137fc
Contents?: true
Size: 974 Bytes
Versions: 1
Compression:
Stored size: 974 Bytes
Contents
module Ecrire class PostsController < ::ApplicationController # TODO: This should be included. I have no idea why this isn't. # It actually is loaded in dev as soon as the reloader reloads the files include Rails.application.routes.url_helpers before_action :pagination, only: :index protect_from_forgery except: :index helper_method :post def index respond_to do |format| format.html format.rss format.json do headers['Access-Control-Allow-Origin'] = '*' end end end def show redirect_to :root and return if post.nil? redirect_to :root and return unless post.published? end protected def posts @post ||= Post.published.page(params[:page]).per(params[:per]).order(:published_at) end def post @post ||= Post.find_by_slug(params[:id]) end def pagination params[:per] ||= 10 params[:page] ||= 1 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ecrire-0.20.0 | lib/ecrire/app/controllers/ecrire/posts_controller.rb |