Sha256: c2dd564b057684e10a776258eaebf1569faba5c4aa99ebb6c35611acec199233

Contents?: true

Size: 721 Bytes

Versions: 66

Compression:

Stored size: 721 Bytes

Contents

class User < ActiveRecord::Base
  include DeviseTokenAuth::Concerns::User

  validates :operating_thetan, numericality: true, allow_nil: true
  validate :ensure_correct_favorite_color

  def ensure_correct_favorite_color

    if favorite_color and favorite_color != ""
      unless ApplicationHelper::COLOR_NAMES.any?{ |s| s.casecmp(favorite_color)==0 }
        matches = ApplicationHelper::COLOR_SEARCH.search(favorite_color)
        closest_match = matches.last[:string]
        second_closest_match = matches[-2][:string]
        errors.add(:favorite_color, "We've never heard of the color \"#{favorite_color}\". Did you mean \"#{closest_match}\"? Or perhaps \"#{second_closest_match}\"?")
      end
    end
  end
end

Version data entries

66 entries across 66 versions & 3 rubygems

Version Path
devise_token_auth-0.1.43 test/dummy/app/models/user.rb
digix_devise_token_auth-0.1.44 test/dummy/app/models/user.rb
devise_token_auth-0.1.43.beta1 test/dummy/app/models/user.rb
devise_token_auth-0.1.42 test/dummy/app/models/user.rb
devise_token_auth-0.1.41 test/dummy/app/models/user.rb
devise_token_auth-0.1.40 test/dummy/app/models/user.rb
devise_token_auth-0.1.39 test/dummy/app/models/user.rb
devise_token_auth-0.1.38 test/dummy/app/models/user.rb
devise_token_auth-0.1.37 test/dummy/app/models/user.rb
devise_token_auth-0.1.37.beta4 test/dummy/app/models/user.rb
cm-devise_token_auth-0.1.30.1 test/dummy/app/models/user.rb
devise_token_auth-0.1.37.beta3 test/dummy/app/models/user.rb
devise_token_auth-0.1.37.beta2 test/dummy/app/models/user.rb
devise_token_auth-0.1.37.beta1 test/dummy/app/models/user.rb
devise_token_auth-0.1.36 test/dummy/app/models/user.rb
devise_token_auth-0.1.35 test/dummy/app/models/user.rb
devise_token_auth-0.1.34 test/dummy/app/models/user.rb
devise_token_auth-0.1.33 test/dummy/app/models/user.rb
devise_token_auth-0.1.32 test/dummy/app/models/user.rb
devise_token_auth-0.1.32.beta10 test/dummy/app/models/user.rb