Sha256: 2448fae04633ca4cb5fd525d2df6b72b6dc54497de234e1e028f6610d1424f67

Contents?: true

Size: 518 Bytes

Versions: 3

Compression:

Stored size: 518 Bytes

Contents

# encoding: UTF-8

module BeerDb
  module Model

class Drink < ActiveRecord::Base

  belongs_to :beer, class_name: 'BeerDb::Model::Beer'
  belongs_to :user, class_name: 'BeerDb::Model::User'

  before_save :on_before_save

  def on_before_save
    # todo/check: can we use blank? for datetime too or just array,strings,etc.
    #  check - can we use/access created_at? already set for new records?

    self.drunk_at = Time.now   if drunk_at.blank?
  end


end # class Drink

  end # module Model
end # module BeerDb

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
beerdb-note-0.1.0 lib/beerdb/note/models/drink.rb
beerdb-0.9.4 lib/beerdb/models/drink.rb
beerdb-0.9.3 lib/beerdb/models/drink.rb