Class: IshManager::EmailTemplatesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshManager::EmailTemplatesController
- Defined in:
- app/controllers/ish_manager/email_templates_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
before_action :set_lists, only: %i| new |.
- #destroy ⇒ Object
- #edit ⇒ Object
- #iframe_src ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
before_action :set_lists, only: %i| new |
6 7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 6 def create :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..join(', ')}." end redirect_to action: :index end |
#destroy ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 17 def destroy :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 |
#edit ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 28 def edit @tmpl = @email_template = Ish::EmailTemplate.where({ id: params[:id] }).first :edit, @tmpl # @ctx = @email_context = Ish::EmailContext.new render layout: 'ish_manager/application_fullwidth' end |
#iframe_src ⇒ Object
36 37 38 39 40 41 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 36 def iframe_src @tmpl = @email_template = Ish::EmailTemplate.where({ id: params[:id] }).first || Ish::EmailTemplate.find_by({ slug: params[:id] }) :iframe_src, @email_template render layout: false end |
#index ⇒ Object
43 44 45 46 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 43 def index :index, Ish::EmailTemplate @templates = Ish::EmailTemplate.all.order_by( slug: :asc ).page( params[:templates_page] ) end |
#new ⇒ Object
48 49 50 51 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 48 def new @new_email_template = Ish::EmailTemplate.new :new, Ish::EmailTemplate end |
#show ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 53 def show :show, Ish::EmailTemplate @templates = Ish::EmailTemplate.all.page( params[:templates_page] ) @tmpl = @email_template = Ish::EmailTemplate.where({ id: params[:id] }).first || Ish::EmailTemplate.find_by({ slug: params[:id] }) @ctx = @email_context = ::Ish::EmailContext.new({ body: Ish::LoremIpsum.html }) end |
#update ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 62 def update @template = Ish::EmailTemplate.where({ id: params[:id] }).first :update, @template flag = @template.update_attributes( params[:ish_email_template].permit! ) if flag flash[:notice] = 'Success.' else flash[:alert] = "No luck. #{@template.errors..join(', ')}" end redirect_to action: :edit end |