Sha256: e1ce5e2b2661360d2131ececb5df43bad1f97ffe14b6d73ba740926de0ba512c
Contents?: true
Size: 1.62 KB
Versions: 6
Compression:
Stored size: 1.62 KB
Contents
class Pulitzer::PostTypesController < Pulitzer::ApplicationController before_action :get_post_type, except: [:index, :new, :create] def index if params[:post_type_kind] @post_type_kind = params[:post_type_kind] else @post_type_kind = 'template' end if request.xhr? if Pulitzer.skip_metadata_auth? || self.instance_eval(&Pulitzer.metadata_closure) @post_types = Pulitzer::PostType.send(@post_type_kind).order(name: :asc) else @post_types = Pulitzer::PostType.send(@post_type_kind).joins(:post_type_versions).where(pulitzer_post_type_versions: {status: 'published'}).distinct.order(name: :asc) end render_ajax end end def new @post_type = Pulitzer::PostType.new(post_type_params) render partial: 'new', locals: {post_type: @post_type} end def create @post_type = Pulitzer::PostType.create(post_type_params) CreateTemplateVersion.new(@post_type).call render partial: 'show_wrapper', locals: {post_type: @post_type} end def show render partial: 'show', locals: {post_type: @post_type} end def edit render partial: 'form', locals: {post_type: @post_type} end def update @post_type.update_attributes(post_type_params) Pulitzer::UpdateSingletonPost.new(@post_type, post_params_name).call render partial: 'show', locals: {post_type: @post_type} end def destroy @post_type.destroy head :ok end protected def post_type_params params[:post_type].permit! end def post_params_name params[:post_type][:name] end def get_post_type @post_type = Pulitzer::PostType.find(params[:id]) end end
Version data entries
6 entries across 6 versions & 1 rubygems