Sha256: 3d4db47019686af0372cef7bad89e0f880bed5923f851fa8594d68e7d8bf5837

Contents?: true

Size: 1.33 KB

Versions: 64

Compression:

Stored size: 1.33 KB

Contents

class IshManager::TagsController < IshManager::ApplicationController

  before_action :set_lists

  def index
    @tags = Tag.unscoped.where( :parent_tag_id => nil ).order_by( :name => :asc )
    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!
    authorize! :create, @tag
    if @tag.save
      flash[:notice] = 'Success.'
      redirect_to 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
    
    # byebug

    if @tag.update_attributes params[:tag].permit!
      flash[:notice] = 'Success.'
      redirect_to tags_path
    else
      flash[:error] = 'No luck.'
      render :action => :new
    end
  end

  def destroy
    @tag = Tag.unscoped.find params[:id]
    authorize! :destroy, @tag
    if @tag.destroy
      flash[:notice] = 'Success'
    else
      flash[:alert] = "Cannot destroy tag: #{@tag.errors.messages}"
    end
    redirect_to :action => 'index'
  end

end


Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
ish_manager-0.1.8.111 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.110 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.109 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.108 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.107 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.106 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.105 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.104 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.103 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.102 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.101 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.100 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.99 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.98 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.97 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.96 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.95 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.94 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.93 app/controllers/ish_manager/tags_controller.rb
ish_manager-0.1.8.92 app/controllers/ish_manager/tags_controller.rb