Class: Stormpath::Rails::RegistrationForm
- Inherits:
-
Object
- Object
- Stormpath::Rails::RegistrationForm
- Includes:
- ActiveModel::Model
- Defined in:
- app/forms/stormpath/rails/registration_form.rb
Defined Under Namespace
Classes: ArbitraryDataSubmitted, FormError
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ RegistrationForm
constructor
A new instance of RegistrationForm.
- #save ⇒ Object
- #save! ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ RegistrationForm
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/forms/stormpath/rails/registration_form.rb', line 20 def initialize(params = {}) custom_data_params = params[:customData] || {} params = params.except(:customData).merge(custom_data_params) params = params.stringify_keys.transform_keys(&:underscore).symbolize_keys arbitrary_param_names = params.keys - RegistrationFormFields.enabled_field_names if arbitrary_param_names.any? raise ArbitraryDataSubmitted, "Can't submit arbitrary data: #{arbitrary_param_names.join(', ')}" end super(params) end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
6 7 8 |
# File 'app/forms/stormpath/rails/registration_form.rb', line 6 def account @account end |
Instance Method Details
#save ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/forms/stormpath/rails/registration_form.rb', line 34 def save return false if invalid? begin self.account = Stormpath::Rails::Client.application.accounts.create( Stormpath::Resource::Account.new(stormpath_registration_params) ) rescue Stormpath::Error => error errors.add(:base, error.) && false end end |
#save! ⇒ Object
46 47 48 49 |
# File 'app/forms/stormpath/rails/registration_form.rb', line 46 def save! return true if save raise(FormError, errors..first) end |