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
- #destroy ⇒ Object
- #edit ⇒ Object
- #iframe_src ⇒ Object
- #index ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 4 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
15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 15 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
26 27 28 29 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 26 def edit @template = Ish::EmailTemplate.where({ id: params[:id] }).first :edit, @template end |
#iframe_src ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 31 def iframe_src :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 |
#index ⇒ Object
39 40 41 42 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 39 def index :index, Ish::EmailTemplate @templates = Ish::EmailTemplate.all.page( params[:templates_page] ) end |
#show ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 44 def show :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 |
#update ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/ish_manager/email_templates_controller.rb', line 53 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.' redirect_to action: 'index' else flash[:alert] = "No luck. #{@template.errors..join(', ')}" render :edit end end |