Sha256: 8f3a8a94e6224386e53f2cd486862a8d55443cbe43e0f35b0d7a92f07fcf2a5c

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

module Jabe
  class Admin::EntriesController < Admin::BaseController
    helper_method :entry
    before_filter :set_is_draft, :only => [:create, :update]

    def index
      @drafts  = Entry.drafts
      @published = Entry.published.page(params[:page])
    end

    def create
      if entry.save
        redirect_to(admin_entries_path, :notice => message)
      else
        render :new
      end
    end

    def update
      if entry.update_attributes(params[:entry])
        redirect_to(admin_entries_path, :notice => message)
      else
        render :edit
      end
    end

    def destroy
      entry.destroy
      redirect_to admin_entries_path
    end

    private

      def entry
        @entry ||= params[:id].blank? ?
          Entry.new(params[:entry]) :
          Entry.find(params[:id])
      end

      def set_is_draft
        params[:entry][:draft] = (params[:commit] =~ /draft/i).present?
      end

      def message
        entry.draft ? "Entry was saved as a draft." : "Entry was published."
      end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jabe-0.9.1 app/controllers/jabe/admin/entries_controller.rb
jabe-0.9.0 app/controllers/jabe/admin/entries_controller.rb
jabe-0.8.0 app/controllers/jabe/admin/entries_controller.rb
jabe-0.7.0 app/controllers/jabe/admin/entries_controller.rb
jabe-0.6.5 app/controllers/jabe/admin/entries_controller.rb
jabe-0.6.4 app/controllers/jabe/admin/entries_controller.rb
jabe-0.6.3 app/controllers/jabe/admin/entries_controller.rb
jabe-0.6.2 app/controllers/jabe/admin/entries_controller.rb
jabe-0.6.1 app/controllers/jabe/admin/entries_controller.rb
jabe-0.6.0 app/controllers/jabe/admin/entries_controller.rb