Sha256: f0cb50aa6f2a67bb30780a8bf2e6b4dd1a2a78943ebde1d81203c66875c49fe1
Contents?: true
Size: 820 Bytes
Versions: 6
Compression:
Stored size: 820 Bytes
Contents
# encoding: utf-8 module InvoiceBar class ReceiptTemplate < ActiveRecord::Base before_validation :update_amount attr_accessible :name validates :name, :presence => true validate :name_is_unique include InvoiceBar::Billable::Base include InvoiceBar::Billable::Receipting include InvoiceBar::Billable::Associations::Base # Search include InvoiceBar::Searchable def self.searchable_fields ['name'] end private # Validates uniqueness of a name for current user. def name_is_unique invoice_templates = ReceiptTemplate.where(:name => self.name, :user_id => self.user_id) if invoice_templates.any? errors.add(:name, :uniqueness) unless invoice_templates.include? self end end end end
Version data entries
6 entries across 6 versions & 1 rubygems