Sha256: c6c31cfe3d626479a614bf64f71627a4bae63c725c19d49620dfc27349a4079c
Contents?: true
Size: 1.56 KB
Versions: 4
Compression:
Stored size: 1.56 KB
Contents
class Wco::Leadset include Mongoid::Document include Mongoid::Timestamps include Mongoid::Paranoia store_in collection: 'wco_leadsets' field :company_url validates :company_url, presence: true, uniqueness: true index({ company_url: 1 }, { unique: true, name: 'company_url' }) field :email index({ email: 1 }, { name: 'email' }) validates :email, uniqueness: { allow_nil: true } # presence: true has_many :leads, class_name: 'Wco::Lead' has_many :profiles, class_name: 'Wco::Profile', inverse_of: :leadset has_many :appliances, class_name: 'WcoHosting::Appliance', inverse_of: :leadset has_many :subscriptions, class_name: 'Wco::Subscription', inverse_of: :leadset has_and_belongs_to_many :tags, class_name: 'Wco::Tag' has_many :invoices, class_name: 'Wco::Invoice' field :next_invoice_number, type: :integer, default: 100 has_and_belongs_to_many :serverhosts, class_name: 'WcoHosting::Serverhost' # , inverse_of: :leadset def next_serverhost serverhosts.first end ## ## stripe ## field :customer_id def customer_id if self[:customer_id].blank? return nil if !email existing = Stripe::Customer.search({ query: "email: '#{email}'" }) # puts! existing, 'existing' if existing.data.present? update_attributes( customer_id: existing.data[0][:id] ) else customer = Stripe::Customer.create({ email: email }) # puts! customer, 'customer' update_attributes( customer_id: customer[:id] ) end end self[:customer_id] end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
wco_models-3.1.0.50 | app/models/wco/leadset.rb |
wco_models-3.1.0.49 | app/models/wco/leadset.rb |
wco_models-3.1.0.48 | app/models/wco/leadset.rb |
wco_models-3.1.0.47 | app/models/wco/leadset.rb |