Sha256: e3e80cc3a3e8dfbfeaa79d16bad2c21065ad49f99bd0f675b1e228a35f3b2e4d
Contents?: true
Size: 812 Bytes
Versions: 3
Compression:
Stored size: 812 Bytes
Contents
module Theblog class Admin::ItemsController < AdminController include Theblog::Itemable before_action :update_content_status, only: [:draft, :publish, :block, :unblock] def create @item = model.new(permitted_params.merge({author_id: current_account.id})) if @item.save flash[:notice] = "Item created" redirect_to action: :index else render 'new' end end def draft; end def publish; end def block; end def unblock; end private def update_content_status state = params["action"] authorize item, :"#{state}?" item.send("#{state}!") redirect_to :back, notice: "Item is #{state}ed" rescue AASM::InvalidTransition => err redirect_to :back, alert: "Item is not #{state}ed" end end end
Version data entries
3 entries across 3 versions & 1 rubygems