Sha256: f25860c3bd6deffed3983a45a12b49d3ebef27660a96736b33ccae3e263d22d4
Contents?: true
Size: 896 Bytes
Versions: 32
Compression:
Stored size: 896 Bytes
Contents
# frozen_string_literal: true class WCC::Contentful::App::ContactFormController < ApplicationController include WCC::Contentful::App::PreviewPassword def create address = form_model.to_address(email_object_id: params[:email_object_id]) form_model.send_email( form_params.merge!( { notification_email: address, internal_title: params[:internal_title] } ) ) render json: { type: 'success', message: "Thanks for reaching out. We'll be in touch soon!" } end private def form_model raise ArgumentError, 'missing form ID' unless params[:id] @form_model ||= form_class.find( params[:id], options: { preview: preview? } ) end def form_class WCC::Contentful::Model.resolve_constant('section-contact-form') end def form_params params.slice(*form_model.fields.map(&:title)) end end
Version data entries
32 entries across 32 versions & 1 rubygems