Sha256: ffd8082be09c02809c1079ae1d3cfea70432821daccd6d9926510a73f53823d4

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

class Eventable::CategoriesController < Eventable::EventableController

  before_filter :get_categories, :only => [:index]
  before_filter :get_category, :only => [:show, :edit, :update, :destroy]
  before_filter :new_category, :only => [:new, :create]

  def create
    if @category.update_attributes(params[:eventable_category])
      try_after_callback do
        flash[:notice] = 'Category was successfully created.'
        redirect_to(eventable_category_path(@category))
      end
    else
      try_after_callback :fail do
        render :action => "new"
      end
    end
  end

  def update
    if @category.update_attributes(params[:eventable_category])
      try_after_callback do
        flash[:notice] = 'Category was successfully updated.'
        redirect_to(eventable_category_path(@category))
      end
    else
      try_after_callback :fail do
        render :action => "edit"
      end
    end
  end

  def destroy
    @category.destroy
    try_after_callback do
      redirect_to(eventable_categories_path)
    end
  end

  private

  def model
    Eventable::Category
  end

  def get_categories
    @categories = model.all
  end

  def get_category
    @category = model.find(params[:id])
  end

  def new_category
    @category = model.new
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dcs-eventable-0.0.8 app/controllers/eventable/categories_controller.rb