Sha256: a8ece644c5cad55ef2d38f692a1510c325ae6e5f20c453d148bd4148ddba5e25

Contents?: true

Size: 709 Bytes

Versions: 2

Compression:

Stored size: 709 Bytes

Contents

class CanceledAccount < ActiveRecord::Base
  attr_accessor :account

  belongs_to :plan

  before_validation :populate_from_account, :on => :create, :if => :account

  after_create :send_notification

  private

  def populate_from_account
    self.name          = account.name
    self.keyword       = account.keyword
    self.billing_email = account.customer.email
    self.memberships   = account.memberships.to_json(:include => { :user => { :only => [:email, :name, :created_at]}}, :only => [:admin, :created_at])
    self.plan          = account.plan
    self.started_at    = account.created_at
  end

  def send_notification
    BillingMailer.cancelation_notification(self).deliver if account
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
saucy-0.16.1 app/models/canceled_account.rb
saucy-0.16.0 app/models/canceled_account.rb