Sha256: bb94e35893510ef42956c433a4d34c0dffeece4a155ce8a83751d15f9bc3ca67

Contents?: true

Size: 921 Bytes

Versions: 12

Compression:

Stored size: 921 Bytes

Contents

class VoucherUser < ActiveRecord::Base
  attr_accessible :confirmation_date, :confirmed, :email, :name
  
  belongs_to :voucher

  attr_protected :confirmed, :confirmation_date
  validates_presence_of :name, :email
  validates :email, email: true

  after_create :send_confirmation_email


  def confirm
      @confirmed = true
      @confirmation_date = Time.now
      @save
  end

  # @param voucher instance of Voucher
  def already_required(voucher)
      user = VoucherUser.where({voucher_id: voucher[:id], id: @attributes['id']}).first
      if user
          true
      else
          false
      end
  end

  def has_confirmed(voucher)
      user = VoucherUser.where({voucher_id: voucher[:id], id: @attributes['id'], confirmed: true}).first
      if user
          true
      else
          false
      end
  end

  def send_confirmation_email
      VoucherMailer.send_confirmation_link(self).deliver
  end


end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
mix-rails-0.25.1 mix-rails-vouchers/app/models/voucher_user.rb
mix-rails-vouchers-0.25.1 app/models/voucher_user.rb
mix-rails-0.25.0 mix-rails-vouchers/app/models/voucher_user.rb
mix-rails-vouchers-0.25.0 app/models/voucher_user.rb
mix-rails-0.24.1 mix-rails-vouchers/app/models/voucher_user.rb
mix-rails-vouchers-0.24.1 app/models/voucher_user.rb
mix-rails-0.24.0 mix-rails-vouchers/app/models/voucher_user.rb
mix-rails-vouchers-0.24.0 app/models/voucher_user.rb
mix-rails-0.23.1 mix-rails-vouchers/app/models/voucher_user.rb
mix-rails-vouchers-0.23.1 app/models/voucher_user.rb
mix-rails-0.23.0 mix-rails-vouchers/app/models/voucher_user.rb
mix-rails-vouchers-0.23.0 app/models/voucher_user.rb