Sha256: 25a03ac32d37f0222bdff798d079d826b322ccf641c929c95f8ac5fe62f7e43b

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

class IshLibManager::TagsController < IshLibManager::ApplicationController

  before_filter :set_lists

  def index
    @tags = Tag.unscoped
    authorize! :index, Tag.new
  end
  
  def show
    @tag = Tag.unscoped.find params[:id]
    authorize! :show, @tag
  end

  def new
    @tag = Tag.new
    authorize! :new, @tag
  end

  def create
    @tag = Tag.create params[:tag].permit( :name, :name_seo, :descr, :is_public, :is_feature, :is_trash,
                                           :weight, :parent_tag_id, :site_id )
    authorize! :create, @tag
    if @tag.save
      flash[:notice] = 'Success.'
      redirect_to manager_tags_path
    else
      puts! @tag.errors, "error creating tag."
      flash[:error] = "No luck. #{@tag.errors.messages}" 
      render :action => :new
    end
  end

  def edit
    @tag = Tag.unscoped.find params[:id]
    authorize! :edit, @tag
  end

  def update
    @tag = Tag.unscoped.find params[:id]
    authorize! :update, @tag
    if @tag.update_attributes params[:tag].permit( :name, :name_seo, :descr,
                                                   :is_public, :is_trash, :is_feature, :weight,
                                                   :site_id, :parent_tag_id )
      flash[:notice] = 'Success.'
      redirect_to manager_tags_path
    else
      flash[:error] = 'No luck.'
      render :action => :new
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ish_lib_manager-0.0.1 app/controllers/ish_lib_manager/tags_controller.rb