Class: Manage::CmsTemplatesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Manage::CmsTemplatesController
- Defined in:
- app/controllers/manage/cms_templates_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
16 17 18 19 |
# File 'app/controllers/manage/cms_templates_controller.rb', line 16 def create @cms_template = CmsTemplate.new update end |
#edit ⇒ Object
21 22 23 |
# File 'app/controllers/manage/cms_templates_controller.rb', line 21 def edit @cms_template = CmsTemplate.find(params[:id]) end |
#index ⇒ Object
7 8 9 |
# File 'app/controllers/manage/cms_templates_controller.rb', line 7 def index @cms_templates = CmsTemplate.order(:name) end |
#new ⇒ Object
11 12 13 14 |
# File 'app/controllers/manage/cms_templates_controller.rb', line 11 def new @cms_template = CmsTemplate.new render action: 'edit' end |
#update ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/manage/cms_templates_controller.rb', line 25 def update @cms_template ||= CmsTemplate.find(params[:id]) @cms_template.assign_attributes(cms_template_params) begin puts Cms::ContentController.renderer.new('action_dispatch.request.path_parameters' => { controller: '/cms/content', action: 'show', id: @cms_template.pages.last || CmsPage.new }).render inline: @cms_template.content rescue ScriptError, StandardError => e flash.now[:error] = "<pre title=\"#{ERB::Util.html_escape(e.backtrace.join("\n"))}\">#{ERB::Util.html_escape(e.)}</pre>".html_safe render action: 'edit' and return end # this must come after the render_to_string so that we capture template # options embedded in snippets @cms_template. = @cms_template_options if !@cms_template.save flash.now[:error] = @cms_template.errors..join('<br>').html_safe render action: 'edit' else flash[:notice] = 'Template saved.' redirect_to action: 'edit', id: @cms_template end end |