Class: Sincerely::TemplatesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Sincerely::TemplatesController
- Includes:
- Concerns::Pagination
- Defined in:
- app/controllers/sincerely/templates_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #preview ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/sincerely/templates_controller.rb', line 24 def create @template = Sincerely::Templates::EmailLiquidTemplate.new(template_params) if @template.save redirect_to template_path(@template), notice: 'Template created successfully' else render :new, status: :unprocessable_entity end end |
#edit ⇒ Object
22 |
# File 'app/controllers/sincerely/templates_controller.rb', line 22 def edit; end |
#index ⇒ Object
9 10 11 12 |
# File 'app/controllers/sincerely/templates_controller.rb', line 9 def index @pagination = paginate(all_templates) @templates = @pagination[:records] end |
#new ⇒ Object
18 19 20 |
# File 'app/controllers/sincerely/templates_controller.rb', line 18 def new @template = Sincerely::Templates::EmailLiquidTemplate.new end |
#preview ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/sincerely/templates_controller.rb', line 42 def preview render_preview rescue JSON::ParserError render plain: 'Invalid JSON in sample data', status: :bad_request rescue ArgumentError => e render plain: e., status: :bad_request rescue Liquid::Error => e render plain: "Template rendering error: #{e.}", status: :unprocessable_entity end |
#show ⇒ Object
14 15 16 |
# File 'app/controllers/sincerely/templates_controller.rb', line 14 def show @notification_count = template_notification_count end |
#update ⇒ Object
34 35 36 37 38 39 40 |
# File 'app/controllers/sincerely/templates_controller.rb', line 34 def update if @template.update(template_params) redirect_to template_path(@template), notice: 'Template updated successfully' else render :edit, status: :unprocessable_entity end end |