Sha256: 0c1d51aa155247daee000d6a461b57940ffcc5031e00a5a48e3425720902e3db

Contents?: true

Size: 814 Bytes

Versions: 3

Compression:

Stored size: 814 Bytes

Contents

module Panda
  module CMS
    class FormSubmissionsController < ApplicationController
      def create
        vars = params.except(:authenticity_token, :controller, :action, :id)

        form = Panda::CMS::Form.find(params[:id])
        form_submission = Panda::CMS::FormSubmission.create(form_id: params[:id], data: vars.to_unsafe_h)
        form.update(submission_count: form.submission_count + 1)

        Panda::CMS::FormMailer.notification_email(form: form, form_submission: form_submission).deliver_now

        if (completion_path = form&.completion_path)
          redirect_to completion_path
        else
          # TODO: This isn't a great fallback, we should do something nice here...
          # Perhaps a simple JS alert when sent?
          redirect_to "/"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
panda-cms-0.7.3 app/controllers/panda/cms/form_submissions_controller.rb
panda-cms-0.7.2 app/controllers/panda/cms/form_submissions_controller.rb
panda-cms-0.7.0 app/controllers/panda/cms/form_submissions_controller.rb