Sha256: 55b22df27f2a2e411af56bb5a910602954d465784a72bca06889dcd65568a206

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

require_dependency "chive/application_controller"

module Chive
  class ArticlesController < ApplicationController

    def index
      @articles = Article.where('published_at <= ? AND (expired_at >= ? OR expired_at IS NULL)', DateTime.now, DateTime.now).order(published_at: :desc).paginate(page: params[:page], per_page: Chive.per_page)
    end

    def show
      @article = Article.find_by(slug: params[:slug])
    end

    def feed
      @articles = Article.where('published_at <= ? AND (expired_at >= ? OR expired_at IS NULL)', DateTime.now, DateTime.now).order(published_at: :desc).limit(Chive.per_page)
      respond_to do |format|
        format.rss { render layout: false }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chive-0.0.1 app/controllers/chive/articles_controller.rb