Improve unbinded invoice scope #2539

This commit is contained in:
Martin Lensment 2015-07-14 16:15:25 +03:00
parent 8f51d8a867
commit 194a551203

View file

@ -7,7 +7,9 @@ class Invoice < ActiveRecord::Base
accepts_nested_attributes_for :invoice_items
scope :unbinded, -> { where('id NOT IN (SELECT invoice_id FROM account_activities)') }
scope :unbinded, lambda {
where('id NOT IN (SELECT invoice_id FROM account_activities where invoice_id IS NOT NULL)')
}
attr_accessor :billing_email
validates :billing_email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }, allow_blank: true