Sha256: 0636aef8cf5d50ecac9c148fb4726be2b49d037a91aac64963b0eb2e125d2263

Contents?: true

Size: 901 Bytes

Versions: 3

Compression:

Stored size: 901 Bytes

Contents

module Dust
  class PostsController < AuthenticationController

    filter_access_to :all

    layout 'cms'

    def index
      @posts = Post.all
    end

    def new
      @post = Post.new_with_menu_item
    end

    def edit
      @post = Post.find(params[:id])
    end

    def create
      @post = Post.new_with_menu_item(params[:dust_post])

      if @post.save
        redirect_to front_end_post_path(@post.slug), notice: 'Post was successfully created.'
      else
        render action: "new"
      end
    end

    def update
      @post = Post.find(params[:id])

      if @post.update_attributes(params[:dust_post])
        redirect_to front_end_post_path(@post.slug), notice: 'Post was successfully updated.'
      else
        render action: "edit"
      end
    end

    def destroy
      @post = Post.find(params[:id])
      @post.destroy

      redirect_to posts_url
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dust-cms-0.0.07 app/controllers/dust/posts_controller.rb
dust-cms-0.0.06 app/controllers/dust/posts_controller.rb
dust-cms-0.0.05 app/controllers/dust/posts_controller.rb