Sha256: ec4bd305a8c3ab4971808fb7d4bf8af6cb5dc4f02817de748ac2b0a8943312d7

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

module Enjoy::News
  module Controllers
    module News
      extend ActiveSupport::Concern

      def index
        @news = news_class.enabled.after_now.by_date

        unless Enjoy::News.config.news_per_page.nil?
          @news = @news.page(params[:page]).per(Enjoy::News.config.news_per_page)
        end
      end

      def show
        @news = news_class.after_now.find(params[:id])

        if @news and @news.text_slug != params[:id]
          redirect_to @news, status_code: 301
          return true
        end
      end

      private
      def category_class
        Enjoy::News::Category
      end
      def news_class
        Enjoy::News::News
      end
      def page_title
        if @news.class.name == model.name
          @news.page_title
        else
          super
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
enjoy_cms_news-0.4.0.beta3 lib/enjoy/news/controllers/news.rb