Class: RegistrationForm

Inherits:
ApplicationForm show all
Defined in:
app/forms/registration_form.rb

Direct Known Subclasses

AffiliateProgram::MemberForm

Instance Attribute Summary

Attributes inherited from ApplicationForm

#raw_responce

Instance Method Summary collapse

Methods inherited from ApplicationForm

#persisted?

Instance Method Details

#sessionObject



42
43
44
45
46
# File 'app/forms/registration_form.rb', line 42

def session
  @session ||= TranslationCms::Api::Customer.authenticate!(email: email, password: password)
  @session = nil unless @session.nil? || @session.errors.blank?
  @session
end

#submit(is_translator = false) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'app/forms/registration_form.rb', line 31

def submit(is_translator = false)
  api_answer = if is_translator
                 TranslationCms::Api::Translator.create(attributes)
               else
                 TranslationCms::Api::Customer.create(attributes)
               end

  merge_responce! api_answer
  errors.empty?
end