app/models/entities/lead.rb in fat_free_crm-0.13.0 vs app/models/entities/lead.rb in fat_free_crm-0.13.1
- old
+ new
@@ -39,11 +39,11 @@
class Lead < ActiveRecord::Base
belongs_to :user
belongs_to :campaign
belongs_to :assignee, :class_name => "User", :foreign_key => :assigned_to
has_one :contact, :dependent => :nullify # On destroy keep the contact, but nullify its lead_id
- has_many :tasks, :as => :asset, :dependent => :destroy#, :order => 'created_at DESC'
+ has_many :tasks, :as => :asset, :dependent => :destroy
has_one :business_address, :dependent => :destroy, :as => :addressable, :class_name => "Address", :conditions => "address_type='Business'"
has_many :addresses, :dependent => :destroy, :as => :addressable, :class_name => "Address" # advanced search uses this
has_many :emails, :as => :mediator
serialize :subscribed_users, Set
@@ -51,13 +51,13 @@
accepts_nested_attributes_for :business_address, :allow_destroy => true
scope :state, ->(filters) {
where([ 'status IN (?)' + (filters.delete('other') ? ' OR status IS NULL' : ''), filters ])
}
- scope :converted, -> { where(:status => 'converted') }
- scope :for_campaign, ->(id) { where('campaign_id = ?', id) }
- scope :created_by, ->(user) { where('user_id = ?' , user.id) }
- scope :assigned_to, ->(user) { where('assigned_to = ?' , user.id) }
+ scope :converted, -> { where( status: 'converted' ) }
+ scope :for_campaign, ->(id) { where( campaign_id: id ) }
+ scope :created_by, ->(user) { where( user_id: user.id ) }
+ scope :assigned_to, ->(user) { where( assigned_to: user.id ) }
scope :text_search, ->(query) { search('first_name_or_last_name_or_company_or_email_cont' => query).result }
uses_user_permissions
acts_as_commentable