Skip to content

Commit

Permalink
Call downcase_keys and strip_whitespace before creating a user since …
Browse files Browse the repository at this point in the history
…they won't be triggered as before_validations.
  • Loading branch information
rywall committed Mar 8, 2012
1 parent 71cc351 commit c3ef7b5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/devise_invitable/model.rb
Expand Up @@ -56,6 +56,11 @@ def invite!
self.skip_confirmation! if self.new_record? && self.respond_to?(:skip_confirmation!)
generate_invitation_token if self.invitation_token.nil?
self.invitation_sent_at = Time.now.utc

# Call these before_validate methods since we aren't validating on save
self.downcase_keys if self.new_record? && self.respond_to?(:downcase_keys)
self.strip_whitespace if self.new_record? && self.respond_to?(:strip_whitespace)

if save(:validate => false)
self.invited_by.decrement_invitation_limit! if !was_invited and self.invited_by.present?
deliver_invitation unless @skip_invitation
Expand Down

0 comments on commit c3ef7b5

Please sign in to comment.