Sha256: 199411d07fbc378d3e269013f5441a22bfed23a9a2528c0f344465889d72ef7f
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
require_dependency "phcpresspro/application_controller" module Phcpresspro class Article::PostsController < ApplicationController # Include Core Helpers, Security & Action Filters include Phccorehelpers::PhcpluginsproHelper before_action :authenticate_user! before_action :set_paper_trail_whodunnit before_action :set_article_post, only: [:show, :edit, :update, :destroy] # Article Index def index @article_posts = Phcpresspro::Article::Post.where(org_id: current_user.org_id) end # Article Show def show @article_post = Phcpresspro::Article::Post.friendly.find(params[:id]) @versions = Phcpresspro::PostVersions.where(item_id: params[:id], item_type: 'Phcpresspro::Article::Post') end # Article New def new @article_post = Phcpresspro::Article::Post.new end # Article Edit def edit end # POST def create @article_post = Phcpresspro::Article::Post.new(article_post_params) @article_post.user_id = current_user.id @article_post.org_id = current_user.org_id if @article_post.save 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) 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 # Use callbacks to share common setup or constraints between actions. def set_article_post @article_post = Phcpresspro::Article::Post.find(params[:id]) end # Only allow a trusted parameter "white list" through. def article_post_params params.require(:article_post).permit(:psttittle, :psttext, :pststatus, :pstimage, :remove_pstimage, :slug, :user_id, :org_id, category_ids: []) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
phcpresspro-81.0.0 | app/controllers/phcpresspro/article/posts_controller.rb |
phcpresspro-80.3.0 | app/controllers/phcpresspro/article/posts_controller.rb |