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