diff --git a/app/controllers/server/blocks_controller.rb b/app/controllers/server/blocks_controller.rb index 672b50b16fa45a0f422ec3bc441a5c20335f6624..73e7564703ce85d703a9229aa9e891fa7524688d 100644 --- a/app/controllers/server/blocks_controller.rb +++ b/app/controllers/server/blocks_controller.rb @@ -1,25 +1,28 @@ class Server::BlocksController < Server::ApplicationController + before_action :load_template, except: [:index] + def index @templates = Communication::Block.template_kinds.keys breadcrumb end def show - @template = params[:id] - @blocks = Communication::Block.send(@template) breadcrumb add_breadcrumb t("enums.communication.block.template_kind.#{@template}") end def resave - @template = params[:id] - @blocks = Communication::Block.send(@template) @blocks.find_each &:save redirect_to server_block_path(@template), notice: "#{@blocks.count} blocks saved" end protected + def load_template + @template = params[:id] + @blocks = Communication::Block.where(template_kind: @template) + end + def breadcrumb super add_breadcrumb Communication::Block.model_name.human(count: 2), server_blocks_path