Sha256: 3a70ef8b06aea8a2adb4c756f7ec8b0b41f9d239904afeb1c46adf3a770ff4b5

Contents?: true

Size: 666 Bytes

Versions: 11

Compression:

Stored size: 666 Bytes

Contents

module Alchemy
  class AjaxFormsController < Alchemy::BaseController


    def create
      @object = base_class.new permitted_resource_attributes
      if verify_recaptcha(model: @object) && @object.valid?
        #registro dati, invio email
        unless @object.send_only?
        @object.save
        end
        @object.mail_deliver

        render formats: :json
      else
        render formats: :json, status: :not_acceptable
      end
    end


    private


    def permitted_resource_attributes
      params.require(base_class.to_s.demodulize.underscore).permit!
    end

    def base_class
      controller_name.classify.constantize
    end


  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
alchemy-ajax-form-1.2.1 app/controllers/alchemy/ajax_forms_controller.rb
alchemy-ajax-form-2.1.0 app/controllers/alchemy/ajax_forms_controller.rb
alchemy-ajax-form-2.0.0 app/controllers/alchemy/ajax_forms_controller.rb
alchemy-ajax-form-1.2.0 app/controllers/alchemy/ajax_forms_controller.rb
alchemy-ajax-form-1.1.5 app/controllers/alchemy/ajax_forms_controller.rb
alchemy-ajax-form-1.1.3 app/controllers/alchemy/ajax_forms_controller.rb
alchemy-ajax-form-1.1.2 app/controllers/alchemy/ajax_forms_controller.rb
alchemy-ajax-form-1.1.1 app/controllers/alchemy/ajax_forms_controller.rb
alchemy-ajax-form-1.1.0 app/controllers/alchemy/ajax_forms_controller.rb
alchemy-ajax-form-1.0.1 app/controllers/alchemy/ajax_forms_controller.rb
alchemy-ajax-form-1.0.0 app/controllers/alchemy/ajax_forms_controller.rb