Sha256: 70c4ceb2add8ef1f111b00511758978f01e313d16cdefa8a75eb36d42e81b85f

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

require_dependency "flms/application_controller"

module Flms
  class BlocksController < ApplicationController
    before_filter :authenticate_user!
    layout 'flms/admin'

    def index
      @page = Flms::Page.find_by_url params[:page_id]
      @blocks = @page.blocks
    end

    def show
      @block = Block.find(params[:id])
    end

    def new
      @page = Page.find_by_url params[:page_id]
      @block = Block.new
    end

    def edit
      @page = Page.find_by_url params[:page_id]
      @block = Block.find(params[:id])
    end

    def create
      @page = Page.find_by_url params[:page_id]
      @block = Block.new(params[:block])
      if @block.save
        @block.pages << @page
        redirect_to page_blocks_path(@page), notice: 'Block created.'
      else
        render action: "new"
      end
    end

    def update
      @page = Page.find_by_url params[:page_id]
      @block = Block.find(params[:id])
      if @block.update_attributes(params[:block])
        redirect_to [@page, :blocks], notice: 'Block was successfully updated.'
      else
        render action: "edit"
      end
    end

    def destroy
      @page = Page.find_by_url params[:page_id]
      @block = Block.find params[:id]
      @block.destroy
      redirect_to page_blocks_path(@page), notice: 'Block deleted'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flms-0.0.1 app/controllers/flms/blocks_controller.rb