Sha256: 06185678623ce8aacc4788234f53d29a27d035df1847a6ca53ee91059272728a

Contents?: true

Size: 889 Bytes

Versions: 10

Compression:

Stored size: 889 Bytes

Contents

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

  def index
    @drafts  = Entry.drafts
    @published = Entry.published
  end

  def create
    if entry = Entry.create(params[:entry])
      redirect_to(admin_entries_path, :notice => 'Entry was successfully created.')
    else
      render :new
    end
  end

  def update
    if entry.update_attributes(params[:entry])
      redirect_to(admin_entries_path, :notice => 'Entry was successfully updated.')
    else
      render :edit
    end
  end

  def destroy
    entry.destroy
    redirect_to admin_entries_path
  end

  private

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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jabe-0.5.9 app/controllers/admin/entries_controller.rb
jabe-0.5.8 app/controllers/admin/entries_controller.rb
jabe-0.5.7 app/controllers/admin/entries_controller.rb
jabe-0.5.6 app/controllers/admin/entries_controller.rb
jabe-0.5.5 app/controllers/admin/entries_controller.rb
jabe-0.5.4 app/controllers/admin/entries_controller.rb
jabe-0.5.3 app/controllers/admin/entries_controller.rb
jabe-0.5.2 app/controllers/admin/entries_controller.rb
jabe-0.5.1 app/controllers/admin/entries_controller.rb
jabe-0.5.0 app/controllers/admin/entries_controller.rb