Sha256: 9bba0de3fdff61f9fa534bd8038b60d382f5ccd7825796c474c5af62bc448a93

Contents?: true

Size: 450 Bytes

Versions: 3

Compression:

Stored size: 450 Bytes

Contents

# encoding: UTF-8

module BeerDb::Model

class User < ActiveRecord::Base

  has_many :notes # beers w/ ratings
  has_many :drinks

  has_many :bookmarks # bookmarked beers


  before_save :on_before_save

  def on_before_save
    if email.blank?
      self.key = 'xxx'
    else
      # NB: remove whitespace and (.-+_) and downcase
      self.key = email.gsub( /[\s\.\-+_]/, '' ).downcase
    end
  end

end # class User

end # module BeerDb::Model

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
beerdb-0.9.2 lib/beerdb/models/user.rb
beerdb-0.9.1 lib/beerdb/models/user.rb
beerdb-0.9.0 lib/beerdb/models/user.rb