Sha256: ec28831883b428c7faad59f0e190d12fd0e70275344c391ae20f43ccc5baa93e
Contents?: true
Size: 1.47 KB
Versions: 4
Compression:
Stored size: 1.47 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 @galleries = @tag.galleries.page( params[:galleries_page] ).per( 10 ) @videos = @tag.videos.page( params[:videos_page ]).per( 10 ) 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
4 entries across 4 versions & 1 rubygems