Last active
November 12, 2015 19:39
-
-
Save typeoneerror/0cb9f418fa452cb437e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module DokiCore | |
| class AccessRequest | |
| include ActiveModel::Validations | |
| attr_accessor :business, | |
| :email, | |
| :how, | |
| :name, | |
| :subscribed | |
| def initialize(attributes = {}) | |
| @email = attributes[:email] | |
| @name = attributes[:name] | |
| @how = attributes[:how] | |
| @business = attributes[:business] | |
| @subscribed = attributes[:subscribed] | |
| end | |
| validates_presence_of :business, :email, :how, :name, :subscribed | |
| validates :email, 'doki_core/email' => true | |
| def subscribed? | |
| @subscribed.to_i == 1 | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def request_access | |
| @access_request = DokiCore::AccessRequest.new(request_access_params) | |
| if @access_request.valid? | |
| DokiCore::Mailer.access_request_email(@access_request.to_json).deliver_later | |
| if @access_request.subscribed? | |
| DokiCore::SubscribeToMailchimpJob.perform_later(@access_request.email, @access_request.name) | |
| end | |
| redirect_to doki_core.tenant_access_requested_path | |
| else | |
| flash.now[:error] = 'Please correct the issues with the form below' | |
| render :access | |
| end | |
| end |
vinniefranco
commented
Nov 12, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment