Sha256: 8e501eb7afd52a72d7c72dd2ec460397167dc1380707d243db7ce09cb02500d0

Contents?: true

Size: 1.45 KB

Versions: 47

Compression:

Stored size: 1.45 KB

Contents

require_dependency "phcpress/application_controller"

module Phcpress
  class Article::PostsController < ApplicationController

    # Filters & Security
    before_action :set_article_post, only: [:show, :edit, :update, :destroy]

    # Article Index
    def index
      @article_posts = Article::Post.all
    end

    # Article Show
    def show
    end

    # Article New
    def new
      @article_post = Article::Post.new
    end

    # Article Edit
    def edit
    end

    # POST
    def create
      @article_post = Article::Post.new(article_post_params)
      if @article_post.save
        @article_post.connections.build
        redirect_to article_posts_url, notice: 'Post was successfully created.'
        else
          render :new
      end
    end

    # PATCH/PUT
    def update
      if @article_post.update(article_post_params)
        @article_post.connections.build
        redirect_to article_posts_url, notice: 'Post was successfully updated.'
        else
          render :edit
      end
    end

    # DELETE
    def destroy
      @article_post.destroy
      redirect_to article_posts_url, notice: 'Post was successfully destroyed.'
    end

    private

    # Common Callbacks
    def set_article_post
      @article_post = Article::Post.find(params[:id])
    end

    # Params Whitelist
    def article_post_params
      params.require(:article_post).permit(:psttitle, :psttext, :pststatus, :pstimage, :remove_pstimage, category_ids: [])
    end

  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
phcpress-42.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-41.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-40.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-39.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-38.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-37.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-36.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-35.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-34.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-33.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-32.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-31.2.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-31.1.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-31.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-30.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-29.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-28.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-27.0.0 app/controllers/phcpress/article/posts_controller.rb
phcpress-26.0.1 app/controllers/phcpress/article/posts_controller.rb
phcpress-26.0.0 app/controllers/phcpress/article/posts_controller.rb