Sha256: c8f8f900eccc733765f4412b1d628a9ff50e5025d048e3401e94b84413db5d5f

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

class Admin::Blog::TagsController < Admin::Blog::BaseController
  
  before_filter :build_tag, :only => [:new, :create]
  before_filter :load_tag,  :only => [:edit, :update, :destroy]

  def index
    @tags = Blog::Tag.order('is_category DESC', :name)
  end
  
  def edit
    render
  end
  
  def new
    render
  end
  
  def update
    @tag.update_attributes!(params[:tag])
    flash[:notice] = 'Blog Tag updated'
    redirect_to :action => :index
    
  rescue ActiveRecord::RecordInvalid
    flash.now[:error] = 'Failed to update Blog Tag'
    render :action => :edit
  end
  
  def create
    @tag.save!
    flash[:notice] = 'Blog Tag created'
    redirect_to :action => :index
    
  rescue ActiveRecord::RecordInvalid
    flash.now[:error] = 'Failed to create Blog Tag'
    render :action => :new
  end
  
  def destroy
    @tag.destroy
    flash[:notice] = 'Blog Tag removed'
    redirect_to :action => :index
  end

protected
  
  def build_tag
    @tag = Blog::Tag.new(params[:tag])
  end
  
  def load_tag
    @tag = Blog::Tag.find(params[:id])
  rescue ActiveRecord::RecordNotFound
    flash[:error] = 'Blog Tag not found'
    redirect_to :action => :index  
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
comfy_blog-0.1.8 app/controllers/admin/blog/tags_controller.rb
comfy_blog-0.1.7 app/controllers/admin/blog/tags_controller.rb
comfy_blog-0.1.6 app/controllers/admin/blog/tags_controller.rb
comfy_blog-0.1.5 app/controllers/admin/blog/tags_controller.rb
comfy_blog-0.1.4 app/controllers/admin/blog/tags_controller.rb
comfy_blog-0.1.3 app/controllers/admin/blog/tags_controller.rb