Sha256: 16c76c2482d4f0971b175d7fcbf41546622915ac32ba76cc8a22b4725161098e

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

class Manifest::ContentBlocksController < Manifest::ManifestController
  before_filter :authorize_admin, except: [:index, :edit, :update]

  def index
    @content_blocks = ContentBlock.all
  end

  def new
    @content_block = ContentBlock.new(content_block_params)
  end

  def create
    @content_block = ContentBlock.new(content_block_params)

    if @content_block.save
      redirect_to manifest_content_blocks_path
    else
      render 'new'
    end
  end

  def edit
    @content_block = ContentBlock.find(params[:id])
  end

  def update
    @content_block = ContentBlock.find(params[:id])

    if @content_block.update_attributes(content_block_params)
      redirect_to manifest_content_blocks_path
    else
      render 'edit'
    end
  end

  def destroy
    @content_block = ContentBlock.find(params[:id])
    @content_block.destroy

    redirect_to manifest_content_blocks_path
  end

  private

  def content_block_params
    if current_editor.admin?
      params[:content_block]
    else
      params[:content_block].slice(:content)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
manifest-rails-0.1.0 app/controllers/manifest/content_blocks_controller.rb