Sha256: 37ce05918f7a1e464da2b70f9acaae9a891a16ffab7d102cb6c984e22b9a79cc

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

class Cms::LinksController < Cms::BaseController

  before_filter :set_toolbar_tab
  before_filter :load_section, :only => [:new, :create, :move_to]
  before_filter :load_link, :only => [:edit, :update, :destroy]
  
  def new
    @link = Link.new(:section => @section)
  end

  def create
    @link = Link.new(params[:link])
    @link.section = @section
    if @link.save
      flash[:notice] = "Link was '#{@link.name}' created."
      redirect_to [:cms, @section]
    else
      render :action => "new"
    end
  end
  
  def update
    if @link.update_attributes(params[:link])
      flash[:notice] = "Link '#{@link.name}' was updated"
      redirect_to [:cms, @link.section]
    else
      render :action => 'edit'
    end      
  end
  
  def destroy
    respond_to do |format|
      if @link.destroy
        message = "Link '#{@link.name}' was deleted."
        format.html { flash[:notice] = message; redirect_to(cms_sitemap_url) }
        format.json { render :json => {:success => true, :message => message } }
      else
        message = "Link '#{@link.name}' could not be deleted"
        format.html { flash[:error] = message; redirect_to(cms_sitemap_url) }
        format.json { render :json => {:success => false, :message => message } }
      end
    end    
  end

  protected

    def load_section
      @section = Section.find(params[:section_id])
    end

    def load_link
      @link = Link.find(params[:id])
    end

    def set_toolbar_tab
      @toolbar_tab = :sitemap
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nate-browsercms-3.0.210 app/controllers/cms/links_controller.rb
nate-browsercms-3.0.211 app/controllers/cms/links_controller.rb