Sha256: d1571869602f2f2d12a60617054615ddec186d6380b9ab11002dc12999705b2f

Contents?: true

Size: 1.52 KB

Versions: 8

Compression:

Stored size: 1.52 KB

Contents

class ::IshManager::EmailTemplatesController < ::IshManager::ApplicationController

  def create
    authorize! :create, ::Ish::EmailTemplate
    template = ::Ish::EmailTemplate.create params[:ish_email_template].permit!
    if template.persisted?
      flash[:notice] = 'Success.'
    else
      flash[:alert] = "Could not create an email template: #{template.errors.full_messages.join(', ')}."
    end
    redirect_to action: :index
  end

  def destroy
    authorize! :destroy, ::Ish::EmailTemplate
    @template = Ish::EmailTemplate.where({ id: params[:id] }).first || Ish::EmailTemplate.find_by({ slug: params[:id] })
    if @template.destroy
      flash[:notice] = 'Success.'
    else
      flash[:alert] = 'Cannot destroy this template.'
    end
    redirect_to action: :index
  end

  def iframe_src
    authorize! :iframe_src, Ish::EmailTemplate
    @email_template = Ish::EmailTemplate.where({ id: params[:id] }).first ||
      Ish::EmailTemplate.find_by({ slug: params[:id] })
    @email_ctx = EmailContext.new({ body: Ish::LoremIpsum.html })
    render layout: false
  end

  def index
    authorize! :index, Ish::EmailTemplate
    @templates = Ish::EmailTemplate.all.page( params[:templates_page] )
  end

  def show
    authorize! :show, Ish::EmailTemplate
    @templates = Ish::EmailTemplate.all.page( params[:templates_page] )

    @email_template = Ish::EmailTemplate.where({ id: params[:id] }).first ||
      Ish::EmailTemplate.find_by({ slug: params[:id] })
    @email_ctx = EmailContext.new({ body: Ish::LoremIpsum.html })
  end


end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ish_manager-0.1.8.327 app/controllers/ish_manager/email_templates_controller.rb
ish_manager-0.1.8.326 app/controllers/ish_manager/email_templates_controller.rb
ish_manager-0.1.8.325 app/controllers/ish_manager/email_templates_controller.rb
ish_manager-0.1.8.324 app/controllers/ish_manager/email_templates_controller.rb
ish_manager-0.1.8.323 app/controllers/ish_manager/email_templates_controller.rb
ish_manager-0.1.8.322 app/controllers/ish_manager/email_templates_controller.rb
ish_manager-0.1.8.321 app/controllers/ish_manager/email_templates_controller.rb
ish_manager-0.1.8.320 app/controllers/ish_manager/email_templates_controller.rb